Fix bug in Circle.point_at_angle when angle not in [0, 2 * pi]. (#2613)

When the angle passed to `Circle.point_at_angle` is not in the
interval [0, 2 * pi], an error is thrown.

This commit maps all angles into the interval [0, 2 * pi].
This commit is contained in:
Kian Cross 2022-03-12 16:33:46 +00:00 committed by GitHub
commit ef00ae5e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -575,7 +575,9 @@ class Circle(Arc):
"""
start_angle = angle_of_vector(self.points[0] - self.get_center())
return self.point_from_proportion((angle - start_angle) / TAU)
proportion = (angle - start_angle) / TAU
proportion -= math.floor(proportion)
return self.point_from_proportion(proportion)
@staticmethod
def from_three_points(

View file

@ -289,3 +289,9 @@ def test_vmobject_different_num_points_and_submobjects_become():
a.become(b)
assert np.array_equal(a.points, b.points)
assert len(a.submobjects) == len(b.submobjects)
def test_vmobject_point_at_angle():
a = Circle()
p = a.point_at_angle(4 * PI)
assert np.array_equal(a.points[0], p)