Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

classes ArcBetweenPoints, CurvedArrow, CurvedDoubleArrow

Ben Hambrecht72efc2cad959
diff --git a/topics/geometry.py b/topics/geometry.py
index ec1b3f73f..92bb07bb0 100644
--- a/topics/geometry.py
+++ b/topics/geometry.py
@@ -96,6 +96,47 @@ class Arc(VMobject):
return self
+
+
+class ArcBetweenPoints(Arc):
+
+ def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
+ if angle == 0:
+ raise Exception("Arc with zero curve angle. Use Line instead.")
+
+ midpoint = 0.5 * (start_point + end_point)
+ distance_vector = end_point - start_point
+ normal_vector = np.array([-distance_vector[1], distance_vector[0],0])
+ distance = np.linalg.norm(normal_vector)
+ normal_vector /= distance
+ radius = distance/2 / np.sin(0.5 * angle)
+ l = distance/2 / np.tan(0.5 * angle)
+ arc_center = midpoint + l * normal_vector
+ w = start_point - arc_center
+ if w[0] != 0:
+ start_angle = np.arctan(w[1]/w[0])
+ else:
+ start_angle = np.pi/2
+
+ Arc.__init__(self, angle,
+ radius = radius,
+ start_angle = start_angle,
+ **kwargs)
+ self.move_arc_center_to(arc_center)
+
+class CurvedArrow(ArcBetweenPoints):
+
+ def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
+ ArcBetweenPoints.__init__(self, start_point, end_point, angle = TAU/4, **kwargs)
+ self.add_tip()
+
+class CurvedDoubleArrow(ArcBetweenPoints):
+
+ def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
+ ArcBetweenPoints.__init__(self, start_point, end_point, angle = TAU/4, **kwargs)
+ self.add_tip(at_start = True, at_end = True)
+
+
class Circle(Arc):
CONFIG = {
"color" : RED,