A sphere is moving in a circle. Later the camera is tilted so as to see this from a side. From side, it looks like a to and fro motion.
To animate this, I have to make a sphere go in a circle in a 3d plane. But can't use MoveAlongPath because i have to have control over the angle.
This is for a Physics class. I have to show that circular motion, viewed from sideways is to and fro motion. I also have to do calculations on the angle , that is why I have to control the angle.
Any suggestions?
I tried to do this
from manim import *
class ThreeDCameraRotation(ThreeDScene):
def construct(self):
self.camera.background_color = WHITE
self.set_camera_orientation(phi=0 * DEGREES, theta=0* DEGREES)
axes = ThreeDAxes()
circle = Circle(radius=1, color=RED)
self.add(circle, axes)
sphere = Sphere(radius=0.1,color=RED).shift(RIGHT)
#completed the setup
self.play(MoveAlongPath(sphere, circle), run_time=3, rate_func=linear)
#circular motion
self.move_camera(phi=90 * DEGREES, theta=0 * DEGREES,run_time =2)
#Camera movement
self.wait()
self.move_camera(phi=0 * DEGREES, theta=0 * DEGREES)
#again camera movement
self.wait()
But the problem with this code is that
The rotation does not continue when the camera view is changed
Is there a way to simultaneously run the animation while the angle is changing?
The angle cant be adjusted.
I want the rotation to stop when the radius is at 45 degrees from the x axis....
Is there any way to do that?
self.set_camera_orientation(phi=0 * DEGREES, theta=0* DEGREES)
axes = ThreeDAxes()
circle = Circle(radius=1, color=RED)
path = Arc(radius=1, angle=45*DEGREES,stroke_width=0.1)
self.add(circle, axes)
sphere = Sphere(radius=0.1,color=RED).shift(RIGHT)
Everything = VGroup()
Everything.add(axes)
Everything.add(circle)
Everything.add(sphere)
Everything.add(path)
self.play(Rotate(Everything,90*DEGREES,np.array([0,1,0])),MoveAlongPath(sphere, path), run_time=3, rate_func=linear)
self.wait()
instead of a camera movement, just put everything in a VGroup and rotate it. This allows you to play it along other animations. Also for MoveAlongPath, just use an Arc of a circle if you don't want the full rotation.