summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py
diff options
context:
space:
mode:
authorPurusharth Saxena2020-06-23 18:06:56 +0530
committerGitHub2020-06-23 18:06:56 +0530
commitd0c1b826b41a0a0f93079b6ca755f2cef132ce6e (patch)
tree6c851e4ea4e369c536bb183aa9378926b78dcee6 /FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py
parenta896e8b74b1b4864f24d860ea82e4de46d2ff2c7 (diff)
parent959329ed76fb5350f5f68aeb8937a37b62138890 (diff)
downloadFSF-mathematics-python-code-archive-d0c1b826b41a0a0f93079b6ca755f2cef132ce6e.tar.gz
FSF-mathematics-python-code-archive-d0c1b826b41a0a0f93079b6ca755f2cef132ce6e.tar.bz2
FSF-mathematics-python-code-archive-d0c1b826b41a0a0f93079b6ca755f2cef132ce6e.zip
Merge branch 'master' into master
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py')
-rw-r--r--FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py
new file mode 100644
index 0000000..7b6c0d1
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py
@@ -0,0 +1,46 @@
+from manimlib.imports import *
+
+t_offset = 0
+c_t = 0
+
+class cycloid(Scene):
+ def construct(self):
+
+ cycl = ParametricFunction(
+ lambda t: np.array([
+ t - np.sin(t),
+ 1 - np.cos(t),
+ 0
+ ]), t_min = -2.75*np.pi, t_max = 3*np.pi, color = BLUE
+ ).shift(0.73*RIGHT)
+ wheel_radius = 1
+ wheel_function_path = lambda x : 0 + wheel_radius
+
+ line = FunctionGraph(lambda x : 0, color = BLACK)
+ wheel_path = FunctionGraph(wheel_function_path)
+
+ velocity_factor = 0.25
+ frame_rate = self.camera.frame_rate
+ self.dt = 1 / frame_rate
+
+ wheel = Circle(color = BLACK, radius = 1)
+ dot = Dot(radius = 0.16, color = RED)
+ #dot.move_to(wheel.get_arc_center() + np.array([0,2,0]))
+
+ def update_dot(mob,dt):
+ global t_offset,c_t
+ if dt == 0 and c_t == 0:
+ rate= - velocity_factor * self.dt
+ c_t += 1
+ else:
+ rate = - dt*velocity_factor
+ if dt > 0:
+ c_t = 0
+ mob.move_to(wheel.point_from_proportion(((t_offset + rate))%1))
+ t_offset += rate
+ #self.add(mob.copy())
+
+ #dot.move_to(wheel.get_arc_center() + np.array([0,2,0]))
+ dot.add_updater(update_dot)
+ self.add(wheel,dot, line, cycl)
+ self.play(MoveAlongPath(wheel, wheel_path, run_time = 9, rate_func = linear))