Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active September 10, 2023 09:35
Show Gist options
  • Save uwezi/8510f2eb18c17847a9a24c1862cc3d45 to your computer and use it in GitHub Desktop.
Save uwezi/8510f2eb18c17847a9a24c1862cc3d45 to your computer and use it in GitHub Desktop.
[radians] Radians on a unit circle. #manim #geometry #math #radian #animation #arc
from manim import *
class radClone(Scene):
def construct(self):
npl = NumberPlane(
y_range=[-1.5,1.5,0.5],
y_length=8,
x_range=[-16/9*1.5,+16/9*1.5,0.5],
x_length=16/9*8
)
self.add(npl)
centerDot = Dot(color=WHITE).move_to(npl.c2p(0,0))
movingDot1 = centerDot.copy().set_color(RED)
movingDot2 = centerDot.copy().set_color(RED)
self.play(Create(centerDot))
self.play(Create(movingDot1),Create(movingDot2))
radiusLine = Line(npl.c2p(0,0),npl.c2p(1,0), color=RED)
self.play(
Create(radiusLine),
movingDot2.animate.move_to(npl.c2p(1,0)),
rate_func = rate_functions.linear
)
circle = Circle(
radius = np.linalg.norm(npl.c2p(1,0)-npl.c2p(0,0)),
color = BLUE,
stroke_width=2,
)
self.play(
Create(circle),
Rotate(movingDot2, 2*PI, about_point=npl.c2p(0,0)),
Rotate(radiusLine, 2*PI, about_point=npl.c2p(0,0)),
rate_func = rate_functions.linear,
run_time = 2
)
self.play(
Rotate(movingDot1, -PI/2, about_point=npl.c2p(1,0)),
Rotate(radiusLine, -PI/2, about_point=npl.c2p(1,0)),
rate_func = rate_functions.linear,
run_time = 1
)
radiusLine.reverse_direction()
arc = Arc(
arc_center=circle.get_center(),
radius=circle.radius,
start_angle=0, angle=1,
stroke_width=5,
color=RED
)
self.play(
ReplacementTransform(radiusLine, arc),
movingDot1.animate.move_to(circle.point_at_angle(1)),
rate_func = rate_functions.linear,
run_time = 1
)
radiusLine1 = Line(circle.point_at_angle(0),circle.get_center(), color=TEAL)
radiusLine2 = Line(circle.get_center(),circle.point_at_angle(1), color=TEAL)
angle = always_redraw(lambda:
Sector(
start_angle=0,
angle=radiusLine2.get_angle() % (2*PI),
outer_radius=0.2*circle.radius,
stroke_width=3,
color=TEAL,
fill_opacity=0.6
)
)
self.play(Create(radiusLine1))
self.play(Create(radiusLine2))
self.play(Create(angle))
for i in range(5):
self.add(radiusLine2.copy())
self.play(
Rotate(
VGroup(
radiusLine2,
movingDot1,
movingDot2,
arc,
),
angle=1,
about_point=circle.get_center()
)
)
self.wait()
self.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment