-
Notifications
You must be signed in to change notification settings - Fork 191
Closed
Description
Often, I am given a magnitude and an angle in radians, and I need to create a vector from this.
The current ways to do it:
Vec2d(magnitude, 0.0).rotated(angle)
Vec2d(cos(angle), sin(angle)) * magnitude
It would be nice to have a classmethod that can do this more cleanly:
@classmethod
def from_polar(cls, r, theta):
return cls(cos(theta) * r, sin(theta) * r)
Vec2d.from_polar(magnitude, angle)
I count 6 possible places I could use this in my codebase.
Example:
Apply an impulse of x magnitude, at an angle pointing towards the mouse cursor.
Metadata
Metadata
Assignees
Labels
No labels