-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCIRCULAR MOTION
More file actions
53 lines (50 loc) · 2.25 KB
/
Copy pathCIRCULAR MOTION
File metadata and controls
53 lines (50 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%manim -v WARNING -r 1080,1920 -pqh circular_motion3
from manim import*
class circular_motion3(ThreeDScene):
def construct(self):
self.set_camera_orientation(
phi=0 * DEGREES,
theta=-90* DEGREES,
distance=12,
zoom=1)
# ------------------SET UP ------------------
theta = ValueTracker(0)
r=1.5
axes1 = ThreeDAxes(x_range=(-2, 2, 1),z_range=(-2, 2, 1),y_range=(-2, 2, 1),x_length=12,y_length=12,z_length=12,axis_config={"include_ticks": False,"include_tip": False})
circle = ParametricFunction(lambda u: axes1.c2p(r*np.cos(u),r*np.sin(u)), t_range=[0, 2*PI], color=BLUE)
dot1 = always_redraw(lambda: Dot(point=axes1.c2p(r*np.cos(theta.get_value()),r* np.sin(theta.get_value())),color=RED))
arrow1 =always_redraw(lambda: Arrow(start=axes1.c2p(0,0), end=dot1.get_center(), color=GREEN ,buff=0))
group1=VGroup(circle,dot1,axes1,arrow1)
self.add(group1)
self.play(theta.animate.set_value(2*PI), run_time=4,rate_func=smooth)
self.play(theta.animate.set_value(2*PI+PI/4), run_time=4,rate_func=smooth)
# ------------------COMPONENTS STATIC ARROWS ------------------
alpha=2*PI+PI/4
arrow2 = Arrow(
start=axes1.c2p(r*np.cos(alpha), 0),
end=axes1.c2p(r*np.cos(alpha), r*np.sin(alpha)),
color=YELLOW,
buff=0)
arrow3 = Arrow(
start=axes1.c2p(0, 0),
end=axes1.c2p(r*np.cos(alpha), 0),
color=RED,
buff=0)
vec_gr=VGroup(arrow2,arrow3)
self.play(Create(vec_gr),run_time=2)
self.wait(2)
# ------------------COMPONENTS MOVING ARROWS ------------------
arrow2.add_updater(
lambda a: a.put_start_and_end_on(axes1.c2p(0, 0,0),axes1.c2p(r*np.cos(theta.get_value()),0,0)))
arrow3.add_updater(
lambda a: a.put_start_and_end_on(
axes1.c2p(r*np.cos(theta.get_value()),0),axes1.c2p(r*np.cos(theta.get_value()),r*np.sin(theta.get_value())
)))
self.play(
theta.animate.set_value(alpha + 2*PI),
run_time=4,
rate_func=linear)
# ------------------ FREEZE AGAIN (OPTIONAL) ------------------
arrow1.clear_updaters()
arrow2.clear_updaters()
self.wait(2)