File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ Changelog
8
8
9
9
10
10
New feature: ShapeFilter.rejects_collision()
11
+ New feature: Added Vec2d.polar_tuple
11
12
Optimized Vec2d.angle and Vec2d.angle_degrees
12
13
Improved vec2d documentation
13
14
15
+
14
16
Extra thanks for aetle for a number of suggestions for improvements in this pymunk release
15
17
16
18
Original file line number Diff line number Diff line change @@ -564,6 +564,22 @@ def int_tuple(self) -> Tuple[int, int]:
564
564
"""
565
565
return round (self .x ), round (self .y )
566
566
567
+ @property
568
+ def polar_tuple (self ) -> Tuple [float , float ]:
569
+ """Return this vector as polar coordinates (length, angle)
570
+
571
+ See Vec2d.from_polar() for the inverse.
572
+
573
+ >>> Vec2d(2, 0).polar_tuple
574
+ (2.0, 0.0)
575
+ >>> Vec2d(2, 0).rotated(0.5).polar_tuple
576
+ (2.0, 0.5)
577
+ >>> Vec2d.from_polar(2, 0.5).polar_tuple
578
+ (2.0, 0.5)
579
+
580
+ """
581
+ return self .length , self .angle
582
+
567
583
@staticmethod
568
584
def zero () -> "Vec2d" :
569
585
"""A vector of zero length.
@@ -595,6 +611,8 @@ def ones() -> "Vec2d":
595
611
def from_polar (length : float , angle : float ) -> "Vec2d" :
596
612
"""Create a new Vec2d from a length and an angle (in radians).
597
613
614
+ See Vec2d.polar_tuple for the inverse.
615
+
598
616
>>> Vec2d.from_polar(2, 0)
599
617
Vec2d(2.0, 0.0)
600
618
>>> Vec2d(2, 0).rotated(0.5) == Vec2d.from_polar(2, 0.5)
You can’t perform that action at this time.
0 commit comments