Geometry¶
This module contains pure geometric calculation functions that operate on
Manim primitives (Circle, Line,
Arc) without creating any on-screen mobjects. They are useful
for analytic geometry tasks inside a Scene.
- manim_extensions.geometry.CircleInt(circle1, circle2)[source]¶
Compute the intersection points of two circles.
Solves the geometric intersection of two circles in the XY‑plane.
- Parameters:
- Returns:
A tuple
(point1, point2)where each point is[x, y, 0]if the circles intersect; otherwiseNone.- Return type:
Examples
Example: CircleIntDocExample ¶
from manim import * from manim_extensions import CircleInt, LabelDot class CircleIntDocExample(Scene): def construct(self): c1 = Circle(radius=2, color=BLUE).shift(LEFT) c2 = Circle(radius=2, color=GREEN).shift(RIGHT) pts = CircleInt(c1, c2) self.add(c1, c2) if pts: for i, p in enumerate(pts): self.add(LabelDot(f"P{i+1}", p, label_pos=UP, buff=0.1))
from manim import * from manim_extensions import CircleInt, LabelDot class CircleIntDocExample(Scene): def construct(self): c1 = Circle(radius=2, color=BLUE).shift(LEFT) c2 = Circle(radius=2, color=GREEN).shift(RIGHT) pts = CircleInt(c1, c2) self.add(c1, c2) if pts: for i, p in enumerate(pts): self.add(LabelDot(f"P{i+1}", p, label_pos=UP, buff=0.1))
- manim_extensions.geometry.LineCircleInt(line, circle)[source]¶
Compute the intersection points of a line segment and a circle.
Only points that lie within the segment parameter range
[0, 1]are returned.- Parameters:
- Returns:
Two intersection points as a tuple if the segment cuts the circle twice.
A single
numpy.ndarrayif the segment is tangent to the circle.Noneif there is no intersection.
- Return type:
Examples
Example: LineCircleIntDocExample ¶
from manim import * from manim_extensions import LineCircleInt, LabelDot class LineCircleIntDocExample(Scene): def construct(self): line = Line(LEFT * 3, RIGHT * 3) circle = Circle(radius=1, color=BLUE) pts = LineCircleInt(line, circle) self.add(line, circle) if pts: for p in (pts if isinstance(pts, tuple) else [pts]): self.add(LabelDot("P", p, label_pos=UP, buff=0.1))
from manim import * from manim_extensions import LineCircleInt, LabelDot class LineCircleIntDocExample(Scene): def construct(self): line = Line(LEFT * 3, RIGHT * 3) circle = Circle(radius=1, color=BLUE) pts = LineCircleInt(line, circle) self.add(line, circle) if pts: for p in (pts if isinstance(pts, tuple) else [pts]): self.add(LabelDot("P", p, label_pos=UP, buff=0.1))
- manim_extensions.geometry.LineInt(line1, line2)[source]¶
Compute the intersection of two (infinitely extended) lines.
Calculates the intersection point in the 2‑D plane. The result is not restricted to the segment endpoints.
- Parameters:
- Returns:
The intersection point
[x, y, 0]if the lines are not parallel; otherwiseNone.- Return type:
Examples
Example: LineIntDocExample ¶
from manim import * from manim_extensions import LineInt, LabelDot class LineIntDocExample(Scene): def construct(self): l1 = Line(LEFT * 3, RIGHT * 3) l2 = Line(DOWN * 2, UP * 2) p = LineInt(l1, l2) self.add(l1, l2) if p is not None: self.add(LabelDot("P", p, label_pos=UR, buff=0.1))
from manim import * from manim_extensions import LineInt, LabelDot class LineIntDocExample(Scene): def construct(self): l1 = Line(LEFT * 3, RIGHT * 3) l2 = Line(DOWN * 2, UP * 2) p = LineInt(l1, l2) self.add(l1, l2) if p is not None: self.add(LabelDot("P", p, label_pos=UR, buff=0.1))
- manim_extensions.geometry.LineArcInt(line, arc)[source]¶
Compute the intersection points of a line segment and an arc.
The function checks whether each candidate intersection point actually lies within the angular span of the arc.
- Parameters:
- Returns:
A tuple of two points
([x1, y1, 0], [x2, y2, 0])for two intersections.A single point
[x, y, 0]for one intersection.Noneif there is no intersection.
- Return type:
Examples
Example: LineArcIntDocExample ¶
from manim import * from manim_extensions import LineArcInt, LabelDot class LineArcIntDocExample(Scene): def construct(self): line = Line(LEFT * 2, RIGHT * 2) arc = Arc(start_angle=PI/4, angle=PI, radius=1.5, color=BLUE) pts = LineArcInt(line, arc) self.add(line, arc) if pts: for p in (pts if isinstance(pts, tuple) else [pts]): self.add(LabelDot("P", p, label_pos=UP, buff=0.1))
from manim import * from manim_extensions import LineArcInt, LabelDot class LineArcIntDocExample(Scene): def construct(self): line = Line(LEFT * 2, RIGHT * 2) arc = Arc(start_angle=PI/4, angle=PI, radius=1.5, color=BLUE) pts = LineArcInt(line, arc) self.add(line, arc) if pts: for p in (pts if isinstance(pts, tuple) else [pts]): self.add(LabelDot("P", p, label_pos=UP, buff=0.1))
- manim_extensions.geometry.MobjectInt(mob1, mob2)[source]¶
Compute all intersection points between two mobjects.
Exact formulas are used for
Circle,LineandArccombinations. For arbitraryVMobjectinstances, the boundary is approximated by a polygonal chain and segment–segment intersections are reported. Groups andVGroupinstances are processed recursively over their submobjects.- Parameters:
- Returns:
A list of all intersection points (each a 3-D point). Returns an empty list if the objects do not intersect.
- Return type:
Examples
Example: MobjectIntDocExample ¶
from manim import * from manim_extensions import MobjectInt, LabelDot class MobjectIntDocExample(Scene): def construct(self): c1 = Circle(radius=1.5, color=BLUE).shift(LEFT) c2 = Circle(radius=1.5, color=GREEN).shift(RIGHT) line = Line(UP * 2, DOWN * 2, color=RED) pts = [] pts.extend(MobjectInt(c1, c2)) pts.extend(MobjectInt(c1, line)) self.add(c1, c2, line) for i, p in enumerate(pts): self.add(LabelDot(f"P{i+1}", p, label_pos=UP, buff=0.1))
from manim import * from manim_extensions import MobjectInt, LabelDot class MobjectIntDocExample(Scene): def construct(self): c1 = Circle(radius=1.5, color=BLUE).shift(LEFT) c2 = Circle(radius=1.5, color=GREEN).shift(RIGHT) line = Line(UP * 2, DOWN * 2, color=RED) pts = [] pts.extend(MobjectInt(c1, c2)) pts.extend(MobjectInt(c1, line)) self.add(c1, c2, line) for i, p in enumerate(pts): self.add(LabelDot(f"P{i+1}", p, label_pos=UP, buff=0.1))
- manim_extensions.geometry.TangentPoint(p1, p2, line_start, line_end)[source]¶
Compute the tangent point of a circle through two points and a line.
Given two points p1 and p2 that lie on a circle, and a line segment defined by line_start and line_end, this function finds the point on the line segment where the circle is tangent to the line.
- Parameters:
p1 (
Union[ndarray,tuple,list]) – First point on the circle, as(x, y)or(x, y, z).p2 (
Union[ndarray,tuple,list]) – Second point on the circle, as(x, y)or(x, y, z).line_start (
Union[ndarray,tuple,list]) – Start point of the line segment, as(x, y)or(x, y, z).line_end (
Union[ndarray,tuple,list]) – End point of the line segment, as(x, y)or(x, y, z).
- Returns:
The tangent point
(x, y, 0)as anumpy.ndarray, orNoneif no valid tangent point exists.- Return type:
Examples
Example: TangentPointDocExample ¶
from manim import * from manim_extensions import TangentPoint, LabelDot class TangentPointDocExample(Scene): def construct(self): p1 = Dot([1, 0, 0], color=BLUE) p2 = Dot([-1, 0, 0], color=BLUE) line = Line([0, -2, 0], [0, 2, 0]) tangent = TangentPoint( p1.get_center(), p2.get_center(), line.get_start(), line.get_end(), ) self.add(p1, p2, line) if tangent is not None: self.add(LabelDot("T", tangent, label_pos=RIGHT, buff=0.1))
from manim import * from manim_extensions import TangentPoint, LabelDot class TangentPointDocExample(Scene): def construct(self): p1 = Dot([1, 0, 0], color=BLUE) p2 = Dot([-1, 0, 0], color=BLUE) line = Line([0, -2, 0], [0, 2, 0]) tangent = TangentPoint( p1.get_center(), p2.get_center(), line.get_start(), line.get_end(), ) self.add(p1, p2, line) if tangent is not None: self.add(LabelDot("T", tangent, label_pos=RIGHT, buff=0.1))