Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8b9a40f
#added some examples to the camera scene
kolibril13 Sep 19, 2020
219c8f6
#added 3 ZoomedScene examples
kolibril13 Sep 19, 2020
e962187
#removed accidentally added files
kolibril13 Sep 19, 2020
ab0b262
#added updater examples
kolibril13 Sep 20, 2020
f207cba
#added text examples
kolibril13 Sep 21, 2020
ff6ef7b
#renamed example
kolibril13 Sep 21, 2020
2e0df50
#added 3d example with other light source
kolibril13 Sep 21, 2020
494e57c
#added imagemobject examples
kolibril13 Sep 21, 2020
b932504
# added one line of code
kolibril13 Sep 21, 2020
29c1539
# small fix
kolibril13 Sep 21, 2020
436ea3c
# added 3d examples
kolibril13 Sep 24, 2020
2e32d96
# added one advanced project
kolibril13 Sep 24, 2020
58b4233
fixed error
kolibril13 Sep 24, 2020
ee0c1c3
small changes
kolibril13 Sep 24, 2020
3e8145e
3d render
kolibril13 Sep 24, 2020
0ce2ba1
another idea with the file 3d_fix.rst
kolibril13 Sep 24, 2020
69b8670
Merge branch 'master' into more_for_docs
kolibril13 Sep 24, 2020
38fa13d
# one more change
kolibril13 Sep 24, 2020
2978804
some more formula examples
kolibril13 Sep 24, 2020
9305baf
fix indent
kolibril13 Sep 24, 2020
f5aa9a0
remove reference to examples/3d_fix
behackl Sep 27, 2020
0673f1d
change default resolution for videos in doc to 480p30
behackl Sep 27, 2020
40ae5d7
Apply suggestions leotrs
kolibril13 Sep 28, 2020
7ad3136
Added credits and 3d scene changes
kolibril13 Sep 28, 2020
0ef8427
# removed unnecessary lines
kolibril13 Sep 28, 2020
db8cd79
# implemented lots of changes suggested be leotrs
kolibril13 Sep 28, 2020
69737f8
# updated credits
kolibril13 Sep 28, 2020
6f1f19f
# updated scene names
kolibril13 Sep 28, 2020
834aba5
Update docs/source/examples/shapes.rst
kolibril13 Sep 28, 2020
53ec42d
updated credits
kolibril13 Sep 28, 2020
03e8312
updated examples entery
kolibril13 Sep 28, 2020
1aad7e6
Update camera_settings.rst
kolibril13 Sep 28, 2020
01f07d2
changed two lines
kolibril13 Sep 28, 2020
093be8e
Update shapes.rst
kolibril13 Oct 2, 2020
82aea6b
Update plots.rst
kolibril13 Oct 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Examples
examples/camera_settings
examples/animations
examples/neat_projects
examples/advanced_projects
examples/advanced_projects
62 changes: 61 additions & 1 deletion docs/source/examples/3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
=================================

.. manim:: Example3DNo1
:quality: medium
:save_last_frame:

class Example3DNo1(ThreeDScene):
Expand All @@ -19,3 +18,64 @@
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()

89 changes: 88 additions & 1 deletion docs/source/examples/advanced_projects.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,91 @@
Advanced Projects
=================================

This page is currently under construction. It will feature a selection of advanced projects built with manim.
.. manim:: ExampleSineCurve

class ExampleSineCurve(Scene):
# contributed by heejin_park, https://infograph.tistory.com/230
def construct(self):
self.show_axis()
self.show_circle()
self.move_dot_and_draw_curve()
self.wait()

def show_axis(self):
x_start = np.array([-6,0,0])
x_end = np.array([6,0,0])

y_start = np.array([-4,-2,0])
y_end = np.array([-4,2,0])

x_axis = Line(x_start, x_end)
y_axis = Line(y_start, y_end)

self.add(x_axis, y_axis)
self.add_x_labels()

self.orgin_point = np.array([-4,0,0])
self.curve_start = np.array([-3,0,0])

def add_x_labels(self):
x_labels = [
TexMobject("\pi"), TexMobject("2 \pi"),
TexMobject("3 \pi"), TexMobject("4 \pi"),
]

for i in range(len(x_labels)):
x_labels[i].next_to(np.array([-1 + 2*i, 0, 0]), DOWN)
self.add(x_labels[i])

def show_circle(self):
circle = Circle(radius=1)
circle.move_to(self.orgin_point)

self.add(circle)
self.circle = circle

def move_dot_and_draw_curve(self):
orbit = self.circle
orgin_point = self.orgin_point

dot = Dot(radius=0.08, color=YELLOW)
dot.move_to(orbit.point_from_proportion(0))
self.t_offset = 0
rate = 0.25

def go_around_circle(mob, dt):
self.t_offset += (dt * rate)
# print(self.t_offset)
mob.move_to(orbit.point_from_proportion(self.t_offset % 1))

def get_line_to_circle():
return Line(orgin_point, dot.get_center(), color=BLUE)

def get_line_to_curve():
x = self.curve_start[0] + self.t_offset * 4
y = dot.get_center()[1]
return Line(dot.get_center(), np.array([x,y,0]), color=YELLOW_A, stroke_width=2 )


self.curve = VGroup()
self.curve.add(Line(self.curve_start,self.curve_start))
def get_curve():
last_line = self.curve[-1]
x = self.curve_start[0] + self.t_offset * 4
y = dot.get_center()[1]
new_line = Line(last_line.get_end(),np.array([x,y,0]), color=YELLOW_D)
self.curve.add(new_line)

return self.curve

dot.add_updater(go_around_circle)

origin_to_circle_line = always_redraw(get_line_to_circle)
dot_to_curve_line = always_redraw(get_line_to_curve)
sine_curve_line = always_redraw(get_curve)

self.add(dot)
self.add(orbit, origin_to_circle_line, dot_to_curve_line, sine_curve_line)
self.wait(8.5)

dot.remove_updater(go_around_circle)
99 changes: 90 additions & 9 deletions docs/source/examples/animations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,98 @@ Updaters
##########

.. manim:: Updater1Example
:quality: medium

class Updater1Example(Scene):
def construct(self):
curve_reference = Line(ORIGIN, LEFT).set_color(GREEN)
self.add(curve_reference)
def my_rotation_updater(mobj,dt):
mobj.rotate_about_origin(dt)
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
line_moving = Line(ORIGIN, LEFT).set_color(BLUE)
line_moving.add_updater(my_rotation_updater)
self.add(line_reference, line_moving)
self.wait(PI)

def update_curve(mob, dt):
mob.rotate_about_origin(dt)
.. manim:: Updater2Example

curve2 = Line(ORIGIN, LEFT)
curve2.add_updater(update_curve)
self.add(curve_reference, curve2)
self.wait(PI)
class Updater2Example(Scene):
def construct(self):
def updater_forth(mobj, dt):
mobj.rotate_about_origin(dt)
def updater_back(mobj, dt):
mobj.rotate_about_origin(-dt)
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
line_moving = Line(ORIGIN, LEFT).set_color(YELLOW)
line_moving.add_updater(updater_forth)
self.add(line_reference, line_moving)
self.wait(2)
line_moving.remove_updater(updater_forth)
line_moving.add_updater(updater_back)
self.wait(2)
line_moving.remove_updater(updater_back)
self.wait(0.5)

.. manim:: Example3

class Example3(Scene):
def construct(self):
number_line = NumberLine() ##with all your parameters and stuff
pointer = Vector(DOWN)
label = MathTex("x").add_updater(lambda m: m.next_to(pointer, UP))

pointer_value = ValueTracker(0)
pointer.add_updater(
lambda m: m.next_to( number_line.n2p(pointer_value.get_value()), UP)
)
self.add(number_line, pointer, label)
self.play(pointer_value.set_value, 5)
self.wait()
self.play(pointer_value.set_value, 3)

.. manim:: Example4

class Example4(Scene):
def construct(self):
path = VMobject()
dot = Dot()
path.set_points_as_corners([dot.get_center(), dot.get_center()])
def update_path(path):
previus_path = path.copy()
previus_path.add_points_as_corners([dot.get_center()])
path.become(previus_path)
path.add_updater(update_path)
self.add(path, dot)
self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2))
self.wait()
self.play(dot.shift, UP)
self.play(dot.shift, LEFT)
self.wait()

.. manim:: Example1ValTracker

class Example1ValTracker(Scene):
def construct(self):
dot_disp = Dot().set_color(RED)
self.add(dot_disp)
tick_start = 1
tick_end = 2
val_tracker = ValueTracker(tick_start)
def dot_updater(mob):
mob.set_y(val_tracker.get_value())
dot_disp.add_updater(dot_updater)
self.play(val_tracker.set_value, tick_end, rate_func=linear)
self.wait()

.. manim:: Example2ValTracker

class Example2ValTracker(Scene):
def construct(self):
tick_start = 0
tick_end = 2 * PI
val_tracker = ValueTracker(tick_start)
def my_rotation_updater(mobj):
mobj.rotate_about_origin(1 / 30) # be careful: This is framerate dependent!
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
line_moving = Line(ORIGIN, LEFT).set_color(ORANGE)
line_moving.add_updater(my_rotation_updater)
self.add(line_reference, line_moving)
self.play(val_tracker.set_value, tick_end, run_time=PI)
1 change: 0 additions & 1 deletion docs/source/examples/annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Annotations
=================================

.. manim:: AnnotateBrace
:quality: medium
:save_last_frame:

class AnnotateBrace(Scene):
Expand Down
Loading