Skip to content

Commit

Permalink
Rename some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan050 committed Dec 17, 2024
1 parent cc47f39 commit d360a5b
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions manim/mobject/geometry/polygram.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,18 @@ def construct(self):

new_points: list[Point3D] = []

for vertices in self.get_vertex_groups():
for vertex_group in self.get_vertex_groups():
arcs = []

# Repeat the radius list as necessary in order to provide a radius
# for each vertex.
if isinstance(radius, (int, float)):
radius_list = [radius] * len(vertices)
radius_list = [radius] * len(vertex_group)
else:
radius_list = radius * ceil(len(vertices) / len(radius))
radius_list = radius * ceil(len(vertex_group) / len(radius))

for currentRadius, (v1, v2, v3) in zip(
radius_list, adjacent_n_tuples(vertices, 3)
for current_radius, (v1, v2, v3) in zip(
radius_list, adjacent_n_tuples(vertex_group, 3)
):
vect1 = v2 - v1
vect2 = v3 - v2
Expand All @@ -246,10 +246,10 @@ def construct(self):

angle = angle_between_vectors(vect1, vect2)
# Negative radius gives concave curves
angle *= np.sign(currentRadius)
angle *= np.sign(current_radius)

# Distance between vertex and start of the arc
cut_off_length = currentRadius * np.tan(angle / 2)
cut_off_length = current_radius * np.tan(angle / 2)

# Determines counterclockwise vs. clockwise
sign = np.sign(np.cross(vect1, vect2)[2])
Expand All @@ -264,17 +264,17 @@ def construct(self):

if evenly_distribute_anchors:
# Determine the average length of each curve
nonZeroLengthArcs = [arc for arc in arcs if len(arc.points) > 4]
if len(nonZeroLengthArcs):
totalArcLength = sum(
[arc.get_arc_length() for arc in nonZeroLengthArcs]
nonzero_length_arcs = [arc for arc in arcs if len(arc.points) > 4]
if len(nonzero_length_arcs) > 0:
total_arc_length = sum(
[arc.get_arc_length() for arc in nonzero_length_arcs]
)
totalCurveCount = (
sum([len(arc.points) for arc in nonZeroLengthArcs]) / 4
num_curves = (
sum([len(arc.points) for arc in nonzero_length_arcs]) / 4
)
averageLengthPerCurve = totalArcLength / totalCurveCount
average_arc_length = total_arc_length / num_curves
else:
averageLengthPerCurve = 1
average_arc_length = 1.0

# To ensure that we loop through starting with last
arcs = [arcs[-1], *arcs[:-1]]
Expand All @@ -287,9 +287,7 @@ def construct(self):

# Make sure anchors are evenly distributed, if necessary
if evenly_distribute_anchors:
line.insert_n_curves(
ceil(line.get_length() / averageLengthPerCurve)
)
line.insert_n_curves(ceil(line.get_length() / average_arc_length))

new_points.extend(line.points)

Expand Down

0 comments on commit d360a5b

Please sign in to comment.