Mobjects

class manim_extensions.compass.Compass(span=1.5, head_color=ManimColor('#FFFFFF'), niddle_color=ManimColor('#FC6255'), pen_color=ManimColor('#F7D96F'), stroke_width=2, leg_length=3.1, leg_width=0.12, r=0.2, **kwargs)[source]

Bases: VGroup

Compass mobject.

Example: CompassExample

../../_images/CompassExample-2.png
from manim import *

from manim_extensions.compass import Compass

class CompassExample(Scene):
    def construct(self):
        compass = Compass().to_edge(LEFT)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class CompassExample(Scene):
    def construct(self):
        compass = Compass().to_edge(LEFT)
        self.add(compass)

__init__(span=1.5, head_color=ManimColor('#FFFFFF'), niddle_color=ManimColor('#FC6255'), pen_color=ManimColor('#F7D96F'), stroke_width=2, leg_length=3.1, leg_width=0.12, r=0.2, **kwargs)[source]
get_niddle_tip()[source]

Return the coordinates of the needle tip.

get_pen_tip()[source]

Return the coordinates of the pen tip.

get_niddle2pen_vec()[source]

Return the vector from the needle tip to the pen tip.

get_span()[source]

Return the compass span: distance between pen tip and needle tip.

move_niddle_tip_to(pos)[source]

Move the compass as a whole so that the needle tip is at pos.

Example: CompassMoveNiddleTipToDocExample

../../_images/CompassMoveNiddleTipToDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class CompassMoveNiddleTipToDocExample(Scene):
    def construct(self):
        compass = Compass().move_niddle_tip_to(ORIGIN)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class CompassMoveNiddleTipToDocExample(Scene):
    def construct(self):
        compass = Compass().move_niddle_tip_to(ORIGIN)
        self.add(compass)

rotate_about_niddle_tip(angle=1.5707963267948966)[source]

Rotate the compass as a whole around the needle tip by angle.

Example: RotateAboutNiddleTipDocExample

../../_images/RotateAboutNiddleTipDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class RotateAboutNiddleTipDocExample(Scene):
    def construct(self):
        compass = Compass().rotate_about_niddle_tip(PI / 4)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class RotateAboutNiddleTipDocExample(Scene):
    def construct(self):
        compass = Compass().rotate_about_niddle_tip(PI / 4)
        self.add(compass)

reverse_tip()[source]

Mirror-flip the needle tip and pen tip.

Example: ReverseTipDocExample

../../_images/ReverseTipDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class ReverseTipDocExample(Scene):
    def construct(self):
        compass = Compass().reverse_tip()
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class ReverseTipDocExample(Scene):
    def construct(self):
        compass = Compass().reverse_tip()
        self.add(compass)

split_copass_with_gain_angle(angle)[source]

Open the two compass legs by an additional angle.

Example: SplitCompassWithGainAngleDocExample

../../_images/SplitCompassWithGainAngleDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class SplitCompassWithGainAngleDocExample(Scene):
    def construct(self):
        compass = Compass().split_copass_with_gain_angle(PI / 6)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class SplitCompassWithGainAngleDocExample(Scene):
    def construct(self):
        compass = Compass().split_copass_with_gain_angle(PI / 6)
        self.add(compass)

split_compass_with_niddle_tip_fixed(angle, niddle_tip_pos)[source]

Keep the needle tip fixed and open the two compass legs by angle.

Example: SplitCompassWithNiddleTipFixedDocExample

../../_images/SplitCompassWithNiddleTipFixedDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class SplitCompassWithNiddleTipFixedDocExample(Scene):
    def construct(self):
        compass = Compass().split_compass_with_niddle_tip_fixed(PI / 6, ORIGIN)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class SplitCompassWithNiddleTipFixedDocExample(Scene):
    def construct(self):
        compass = Compass().split_compass_with_niddle_tip_fixed(PI / 6, ORIGIN)
        self.add(compass)

get_compass_rotate_angle_direction()[source]

Return whether the two compass legs are counter-clockwise from each other.

Return type:

bool

get_compass_rotate_angle_with_span(span)[source]

Return the angle between the two legs when the compass is opened to span.

Return type:

float

set_compass(span_angle, rotate_angle, niddle_tip_pos)[source]

Set the compass span, rotation angle, and needle tip position.

Example: SetCompassDocExample

../../_images/SetCompassDocExample-1.png
from manim import *
from manim_extensions.compass import Compass

class SetCompassDocExample(Scene):
    def construct(self):
        compass = Compass().set_compass(PI / 6, PI / 4, ORIGIN)
        self.add(compass)
from manim import *
from manim_extensions.compass import Compass

class SetCompassDocExample(Scene):
    def construct(self):
        compass = Compass().set_compass(PI / 6, PI / 4, ORIGIN)
        self.add(compass)

class manim_extensions.compass.Pencil(height=2, angle=0.7853981633974483)[source]

Bases: SVGMobject

Pencil mobject.

Example: PencilDocExample

../../_images/PencilDocExample-1.png
from manim import *
from manim_extensions.compass import Pencil

class PencilDocExample(Scene):
    def construct(self):
        pencil = Pencil().to_edge(LEFT)
        self.add(pencil)
from manim import *
from manim_extensions.compass import Pencil

class PencilDocExample(Scene):
    def construct(self):
        pencil = Pencil().to_edge(LEFT)
        self.add(pencil)

__init__(height=2, angle=0.7853981633974483)[source]
get_nib()[source]

Return the position of the nib.

get_nid_vector()[source]

Return the direction of the pencil body.

move_nid_to(point=array([0., 0., 0.]))[source]

Translate the pencil so that the nib moves to point.

Example: MoveNidToDocExample

../../_images/MoveNidToDocExample-1.png
from manim import *
from manim_extensions.compass import Pencil

class MoveNidToDocExample(Scene):
    def construct(self):
        pencil = Pencil().move_nid_to(ORIGIN)
        self.add(pencil)
from manim import *
from manim_extensions.compass import Pencil

class MoveNidToDocExample(Scene):
    def construct(self):
        pencil = Pencil().move_nid_to(ORIGIN)
        self.add(pencil)

class manim_extensions.compass.Ruler(length=12, width=0.8, ruler_color=ManimColor('#FFFFFF'), stroke_width=2, fill_opacity=0.4, **kwargs)[source]

Bases: VGroup

Ruler mobject.

Example: RulerExample

../../_images/RulerExample-1.png
from manim import *

from manim_extensions.compass import Ruler

class RulerExample(Scene):
    def construct(self):
        ruler = Ruler()
        self.add(ruler)
from manim import *
from manim_extensions.compass import Ruler

class RulerExample(Scene):
    def construct(self):
        ruler = Ruler()
        self.add(ruler)

__init__(length=12, width=0.8, ruler_color=ManimColor('#FFFFFF'), stroke_width=2, fill_opacity=0.4, **kwargs)[source]
get_vecs_of_ruler()[source]

Return the extension and width directions of the ruler.

get_direction_vector_of_ruler()[source]

Return the extension direction of the ruler.

get_width_vector_of_ruler()[source]

Return the width direction of the ruler.

get_start_and_end()[source]

Return the start and end points of the ruler.

get_middle_point()[source]

Return the midpoint of the ruler.

get_length_of_ruler()[source]

Return the length of the ruler.

set_ruler(start=array([-1., 0., 0.]), end=array([1., 0., 0.]))[source]

Place the ruler so that one of its edges aligns with start and end.

Parameters:
  • start – start point of the ruler placement

  • end – end point of the ruler placement

  • manim: (..) –

    SetRulerDocExample: :save_last_frame:

    from manim import * from manim_extensions.compass import Ruler

    class SetRulerDocExample(Scene):
    def construct(self):

    ruler = Ruler().set_ruler(LEFT, RIGHT) self.add(ruler)

put_ruler_flat()[source]

Lay the ruler flat.

Example: PutRulerFlatDocExample

../../_images/PutRulerFlatDocExample-1.png
from manim import *
from manim_extensions.compass import Ruler

class PutRulerFlatDocExample(Scene):
    def construct(self):
        ruler = Ruler().put_ruler_flat()
        self.add(ruler)
from manim import *
from manim_extensions.compass import Ruler

class PutRulerFlatDocExample(Scene):
    def construct(self):
        ruler = Ruler().put_ruler_flat()
        self.add(ruler)