manim/docs/source/examples/3d.rst
kolibril13 5233c598ac
Bunch of more examples for the docs (#458)
* #added some examples to the camera scene

* #added 3 ZoomedScene examples

* #removed accidentally added files

* #added updater examples

* #added text examples

* #renamed example

* #added 3d example with other light source

* #added imagemobject examples

* # added one line of code

* # small fix

* # added 3d examples

* # added one advanced project

* fixed error

* small changes

* 3d render

* another idea with the file 3d_fix.rst

* # one more change

* some more formula examples

* fix indent

* remove reference to examples/3d_fix

* change default resolution for videos in doc to 480p30

* Apply suggestions leotrs

Co-authored-by: Leo Torres <leo@leotrs.com>

* Added credits and 3d scene changes

* # removed unnecessary lines

* # implemented lots of changes suggested be leotrs

* # updated credits

* # updated scene names

* Update docs/source/examples/shapes.rst

Co-authored-by: Leo Torres <leo@leotrs.com>

* updated credits

* updated examples entery

* Update camera_settings.rst

* changed two lines

* Update shapes.rst

* Update plots.rst

Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Co-authored-by: Leo Torres <leo@leotrs.com>
2020-10-02 16:06:01 +02:00

81 lines
2.8 KiB
ReStructuredText

3D Scenes
=================================
.. manim:: Example3DNo1
:save_last_frame:
class Example3DNo1(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
sphere = ParametricSurface(
lambda u, v: np.array([
1.5 * np.cos(u) * np.cos(v),
1.5 * np.cos(u) * np.sin(v),
1.5 * np.sin(u)
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
)
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)
.. manim:: Example3DLightSourcePosition
:save_last_frame:
class Example3DLightSourcePosition(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
sphere = ParametricSurface(
lambda u, v: np.array([
1.5 * np.cos(u) * np.cos(v),
1.5 * np.cos(u) * np.sin(v),
1.5 * np.sin(u)
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
)
self.camera.light_source.move_to(3*IN) # changes the source of the light
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)
.. manim:: Example3DNo3
class Example3DNo3(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
circle=Circle()
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(circle,axes)
self.begin_ambient_camera_rotation(rate=0.1)
self.wait(3)
self.stop_ambient_camera_rotation()
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
self.wait()
.. manim:: Example3DNo4
class Example3DNo4(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
circle=Circle()
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(circle,axes)
self.begin_3dillusion_camera_rotation(rate=2)
self.wait(PI)
self.stop_3dillusion_camera_rotation()
.. manim:: Example3DNo5
:save_last_frame:
class Example3DNo5(ThreeDScene):
def construct(self):
curve1 = ParametricFunction(
lambda u: np.array([
1.2 * np.cos(u),
1.2 * np.sin(u),
u * 0.05
]), color=RED, t_min=-3 * TAU, t_max=5 * TAU,
).set_shade_in_3d(True)
axes = ThreeDAxes()
self.add(axes, curve1)
self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES)
self.wait()