MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / rotate

Method rotate

Python/Turtle.py:166–172  ·  view source on GitHub ↗

rotate self counterclockwise by angle

(self, angle)

Source from the content-addressed store, hash-verified

164 def __abs__(self):
165 return (self[0]**2 + self[1]**2)**0.5
166 def rotate(self, angle):
167 """rotate self counterclockwise by angle
168 """
169 perp = Vec2D(-self[1], self[0])
170 angle = angle * math.pi / 180.0
171 c, s = math.cos(angle), math.sin(angle)
172 return Vec2D(self[0]*c+perp[0]*s, self[1]*c+perp[1]*s)
173 def __getnewargs__(self):
174 return (self[0], self[1])
175 def __repr__(self):

Callers 2

_rotateMethod · 0.45
_rotateMethod · 0.45

Calls 1

Vec2DClass · 0.85

Tested by

no test coverage detected