File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ Changelog
3
3
=========
4
4
.. Pymunk 7.0.0
5
5
Breaking: At least one of the two bodies attached to constraint/joint must be dynamic.
6
- New feature: ShapeFilter.rejects_collision() method
7
- New feature: Vec2d supports bool to test if zero. (bool(Vec2d(2,3) == True)
6
+
7
+ Extra thanks for aetle for a number of suggestions for improvements:
8
+ New feature: ShapeFilter.rejects_collision()
9
+ New feature: Vec2d supports bool to test if zero. (bool(Vec2d(2,3) == True)
8
10
Optimized Vec2d.angle and Vec2d.angle_degrees
11
+ Improved vec2d documentation
9
12
10
13
11
14
Pymunk 6.11.1 (2025-02-09)
Original file line number Diff line number Diff line change @@ -287,12 +287,19 @@ def length(self) -> float:
287
287
def scale_to_length (self , length : float ) -> "Vec2d" :
288
288
"""Return a copy of this vector scaled to the given length.
289
289
290
+ Note that a zero length Vec2d cannot be scaled but will raise an
291
+ exception.
292
+
290
293
>>> Vec2d(1, 0).scale_to_length(10)
291
294
Vec2d(10.0, 0.0)
292
295
>>> '%.2f, %.2f' % Vec2d(10, 20).scale_to_length(20)
293
296
'8.94, 17.89'
294
297
>>> Vec2d(1, 0).scale_to_length(0)
295
298
Vec2d(0.0, 0.0)
299
+ >>> Vec2d(0, 0).scale_to_length(1)
300
+ Traceback (most recent call last):
301
+ ...
302
+ ZeroDivisionError: float division by zero
296
303
"""
297
304
old_length = self .length
298
305
return Vec2d (self .x * length / old_length , self .y * length / old_length )
@@ -374,7 +381,7 @@ def get_angle_degrees_between(self, other: "Vec2d") -> float:
374
381
375
382
def normalized (self ) -> "Vec2d" :
376
383
"""Get a normalized copy of the vector.
377
- Note: This function will return 0 if the length of the vector is 0.
384
+ Note: This function will return a Vec2d(0.0, 0.0) if the length of the vector is 0.
378
385
379
386
>>> Vec2d(3, 0).normalized()
380
387
Vec2d(1.0, 0.0)
You can’t perform that action at this time.
0 commit comments