[1]:
from manim import *
from manim_geometry import *
config.media_embed = True
config.media_width = "100%"
_RV = "-v WARNING -qm --progress_bar None --disable_caching"
_RI = "-v WARNING -s --progress_bar None --disable_caching"
Manim Community v0.18.0
ICircle¶
Internally the library uses these objects to work, these objects are used to obtain intersections and auxiliary objects to make animations.
Intersections¶
[2]:
class ExampleIntersections(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT)
l = Line(LEFT*6, RIGHT*6).shift(DOWN).rotate(30*DEGREES)
ci1, ci2 = c1.intersection_circle(c2)
li1, li2 = c1.intersection_line(l)
ci = VGroup(Dot(ci1), Dot(ci2)).set_color(BLUE)
li = VGroup(Dot(li1), Dot(li2)).set_color(PINK)
self.add(c1, c2, l)
self.add(ci, li)
%manim $_RV ExampleIntersections
Common chord partial¶
[3]:
class ExampleCommonChord(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
common_chord = c1.common_chord_group_partial(c2)
self.add(c1, c2, common_chord)
%manim $_RV ExampleCommonChord
[4]:
class ExampleCommonChord(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
common_chord = c1.common_chord_group_partial(c2, color=BLUE)
self.add(c1, c2, common_chord)
%manim $_RV ExampleCommonChord
[5]:
class ExampleCommonChord(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
common_chord_arc = c1.common_chord_group_partial(c2, only_arc=True, overshot_ang=10*DEGREES)\
.set_color(PINK)
common_chord_line = c1.common_chord_group_partial(c2, only_line=True)\
.set_color(BLUE)
self.add(c1, c2, common_chord_arc, common_chord_line)
%manim $_RV ExampleCommonChord
Common chord complete¶
[6]:
class ExampleLineBisector(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
line_bisector = c1.common_chord_group(c2)
self.add(c1, c2, line_bisector)
%manim $_RV ExampleLineBisector
[7]:
class ExampleLineBisector(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
arc1, arc2 = c1.common_chord_group(c2, only_arcs=True)
arc1.set_color(BLUE)
arc2.set_color(GREEN)
line = c1.common_chord_group(c2, only_line=True)
self.add(c1, c2, arc1, arc2, line)
%manim $_RV ExampleLineBisector
Angle bisector¶
[8]:
class ExampleAngleBisector(Scene):
def construct(self):
c1 = ICircle(3, YELLOW).shift(LEFT)
c2 = ICircle(2, PURPLE).shift(RIGHT*2)
d_red = Dot(DOWN+RIGHT, color=RED)
ref_coord = d_red.get_center()
arc1, arc2, d = grp1 = c1.farthest_angle_bisector_group(
c2, ref_coord, overshot_ang=10*DEGREES
)
arc1.set_color(PINK)
arc2.set_color(ORANGE)
d.set_color(GREEN)
grp2 = c2.nearest_angle_bisector_group(
c1, ref_coord, overshot_ang=0*DEGREES
)
self.add(c1, c2)
self.add(d_red)
self.add(grp1, grp2)
%manim $_RV ExampleAngleBisector
Practical example: Draw hexagon¶
[18]:
class PracticalExample1(Scene):
def setup(self):
c = ICircle(3.5)
c2 = c.copy().move_to(c.get_right())
c2.fade(0.8)
_, i2 = c.intersection_circle(c2)
line = Line(c2.get_center(), i2)
self.circle = c
self.phantom_c = c2.add(Dot(c2.get_center(), z_index=5))
self.line = line
self.add(c, c2, line)
%manim $_RV PracticalExample1
[19]:
class PracticalExample2(PracticalExample1):
def construct(self):
l = self.line
c = self.circle
h = RegularPolygon(6, start_angle=0, radius=c.get_radius())
tmp_circle = self.phantom_c.copy()
for _ in range(6):
tmp_circle = tmp_circle.copy()
tmp_circle.generate_target()
tmp_circle.target.move_to(l.get_end())
arc = tmp_circle.target.common_chord_group_partial(c, only_arc=True)
arc.reverse_points() # Draw in clockwise direction
arc.set_stroke(width=3)
self.play(MoveToTarget(tmp_circle))
self.play(
Rotate(
l,
-arc.angle, # Clockwise rotation
about_point=l.get_end()
),
Create(arc),
)
l.reverse_points() # Invert start and end each step
self.play(FadeOut(l))
self.play(Create(h))
self.wait()
%manim $_RV PracticalExample2
[ ]: