Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions manim/mobject/geometry/polygram.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ def construct(self):

# Distance between vertex and start of the arc
cut_off_length = current_radius * np.tan(angle / 2)
max_cut_off = min(np.linalg.norm(vect1), np.linalg.norm(vect2)) / 2
cut_off_length = np.clip(
cut_off_length,
-max_cut_off,
max_cut_off,
)

# Determines counterclockwise vs. clockwise
sign = np.sign(np.cross(vect1, vect2)[2])
Expand Down
7 changes: 7 additions & 0 deletions tests/module/mobject/geometry/test_unit_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BackgroundRectangle,
Circle,
Line,
Polygon,
Polygram,
Sector,
Square,
Expand Down Expand Up @@ -263,3 +264,9 @@ def test_Circle_point_at_angle():
# Angle 0 should return start point even after reflection
p_reflected_0 = reflected_circle.point_at_angle(0)
np.testing.assert_array_almost_equal(p_reflected_0, reflected_start, decimal=5)


def test_round_corners_collinear_points_stays_finite() -> None:
points = [[-1, 0, 0], [0, 0, 0], [1, 0, 0]]
polygon = Polygon(*points).round_corners(0.15)
assert np.isfinite(polygon.points).all()
Loading