Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20241119_brace3d.py
Last active November 19, 2024 19:34
[Brace 3D] Braces in 3D. #manim #brace3d #brace #threedscene #3D
class brace3D(ThreeDScene):
def construct(self):
axes = ThreeDAxes(
x_range=[-5,5,1],
y_range=[-5,5,1],
z_range=[-5,5,1]
)
self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)
self.add(axes)
@uwezi
uwezi / 20241119_timer.py
Created November 19, 2024 10:31
[timer] A Timer mobject. #manim #animate #decimalnumber #timer
# https://discord.com/channels/581738731934056449/1308355923583963197/1308355923583963197
from manim import *
class Timer(VGroup):
def __init__(self, starttime=99, countdown=True, run=True):
super().__init__()
self.currenttime = starttime
self.starttime = starttime
self.countdown = countdown
self.dorun = run
self.minten = DecimalNumber(0,num_decimal_places=0)
@uwezi
uwezi / 20241029_latex.py
Last active October 29, 2024 22:02
[Aligned LaTeX] Different alignments in LaTeX. #manim #latex #tex #flushleft #flushright #center #minipage
from manim import *
class myParagraph(Scene):
def construct(self):
paragraph = Tex(r'''{12em}
No, this is an awesome paragraph with \\ Newlines and Alignments\\
\begin{center}
center
\end{center}
@uwezi
uwezi / 20241024_intersections.py
Last active October 24, 2024 19:56
[Intersection helpers] Intersections between lines and circles. #manim #geometry #math #circle #line
from manim import *
def circle_line_intersection(circle: Circle, line: Line):
# source https://mathworld.wolfram.com/Circle-LineIntersection.html
cline = line.copy().shift(-circle.get_arc_center())
x0,y0 = circle.get_arc_center()[0:2]
x1,y1 = cline.get_start()[0:2]
x2,y2 = cline.get_end()[0:2]
r = circle.width/2
@uwezi
uwezi / 20241024_heptadecagon.py
Last active October 24, 2024 18:15
[Heptadecagon] Geometric construction of a heptadecagon. #manim #animation #geometry #circle #intersection #line #compass
from manim import *
# https://discord.com/channels/581738731934056449/1298699478194196612/1298699478194196612
class heptadecagon(MovingCameraScene):
def construct(self):
# after https://www.youtube.com/watch?v=xGUWVPOks00 AleeDrawing
self.add(NumberPlane().add_coordinates())
def circle_line_intersection(circle, line):
# source https://mathworld.wolfram.com/Circle-LineIntersection.html
cline = line.copy().shift(-circle.get_arc_center())
@uwezi
uwezi / 20231006_computer_02.svg
Last active October 18, 2024 19:38
[Computer] Animated sequence of a computer adding two numbers. #manim #svg #animate
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@uwezi
uwezi / 20241017_sinxsiny.py
Last active October 17, 2024 16:21
[Triangle construction] Part of a proof for sin(x)sin(y). #manim #triangle #geometry #trigonometry #animation
from manim import *
class sinxsiny(Scene):
def construct(self):
O = Dot([-3,-3.0,0], color=YELLOW, radius=0.05)
A = Dot([3,-3.0,0], color=YELLOW, radius=0.05)
lbl_O = MathTex(r"O").next_to(O,LEFT)
lbl_A = MathTex(r"A").next_to(A,RIGHT)
x = 35*DEGREES
y = 20*DEGREES
@uwezi
uwezi / 20241014_zoomed.py
Last active October 14, 2024 20:47
[Reasonable Zoom Window] Keeping the stroke width outside of the zoomed frame. #manim #zoomedscene #frame
'''
In a zoomed scene the outline stroke of the zoomed rectangular frame protrudes into the zoomed view at high magnification
'''
class ZoomPractice(ZoomedScene):
def construct(self):
ax = NumberPlane(
x_range=[0, 10, 5],
y_range=[0, 150, 50],
x_length=12,
y_length=12,
@uwezi
uwezi / 20241014_connect.py
Last active October 14, 2024 20:43
[Connect the Dots] Three ways to connect a set of dots with lines. #manim #animate #vmobject #line #plotlinegraph #axes
class connectTheDots(Scene):
def construct(self):
xvals = [np.random.uniform(-6.5,6.5) for _ in range(20)]
yvals = [np.random.uniform(-3.5,3.5) for _ in range(20)]
colors = [np.random.choice([RED,GREEN,BLUE,YELLOW,MAROON,ORANGE,WHITE]) for _ in range(20)]
dots = VGroup(
*[Dot(point=[x,y,0], color=c) for x,y,c in zip(xvals,yvals,colors)]
)
self.add(dots)
@uwezi
uwezi / 20241001_autozoom.py
Created October 1, 2024 16:41
[autozoomed scene] A scene which adapts the camera frame to show all mobjects. #manim #movingcamerascene #frame #zoom
# https://discord.com/channels/581738731934056449/1290678443905650819/1290678443905650819
from manim import *
class autozoom(MovingCameraScene):
def construct(self):
sq = Square()
circ = Circle()
self.add(sq,circ)
self.add(self.camera.frame)