Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20260419_radioactive.py
Last active April 19, 2026 20:03
[Radioactive decay] Simulating radioactive decay. #manim #physics #simulate #radioactive
from manim import *
class Atom(Dot):
def __init__(self, pos=ORIGIN, color = RED, prob = 0.1):
super().__init__(point=pos, radius=.07, stroke_width=0, fill_opacity=1, color=color)
self.prob = prob
self.add_updater(self.updater)
def updater(self,mobj,dt):
if (self.prob > 0) and (np.random.uniform(0,1) <= self.prob*dt):
self.prob = 0
@uwezi
uwezi / 20260417_mandala.py
Last active April 17, 2026 12:23
[Mandala] Drawing a mandala. #manim #geometry #bezier
from manim import *
class manadala(Scene):
def construct(self):
center = Dot()
tri = RegularPolygon(n=3, radius=0.5).rotate(PI, about_point=ORIGIN)
circ = Circle(radius = 1)
petarc = VMobject().set_anchors_and_handles(
[np.cos(PI/8),np.sin(PI/8),0],
[1.5*np.cos(PI/8),1.5*np.sin(PI/8),0],
@uwezi
uwezi / 20260415_tile.py
Last active April 15, 2026 18:13
[optimal tiling?] Is this the optimal tiling of an area? #manim #geometry
class tile(Scene):
def construct(self):
for _ in range(10):
# Size rectangleSize = new Size(); # rectangle size will be used as a default value that is the exact aspect ratio desired.
#
# Aspect Ratio = h / w
# where h is the height of the child and w is the width
#
# the numerator will be the aspect ratio and the denominator will always be one
# if you want it to be square just use an aspect ratio of 1
@uwezi
uwezi / 20260407_orbit.py
Last active April 7, 2026 19:54
[Planetary orbits] Orbit simulation. #manim #animation #simulation #newton #planet #physics #orbit
class Planet(VMobject):
def __init__(self,
sun:VMobject=None,
ax:CoordinateSystem=None,
color = BLUE,
radius =0.1,
mass = 6e24,
pos = np.array([150e9,0,0]),
vel = np.array([0,30e3,0]),
G = 6.67e-11,
@uwezi
uwezi / 20260403_sound.py
Created April 3, 2026 18:50
[create sound] Create a tone and play it in Manim. #manim #audio #wav #sound
import wave
import struct
class increaseFreq(Scene):
def construct(self):
fsamp = 44.1e3
f0 = 440
f1 = 880
time = 3
ts = np.linspace(start = 0, stop = time, num=int(fsamp*time))
def f(t):
@uwezi
uwezi / 20260328_hanoi.py
Last active March 30, 2026 11:00
[Towers of Hanoi] Recursive implementation of the game. #manim #game #towersofhanoi #animation
from manim import *
class Disc(VMobject):
def __init__(self, color=RED, width=2, height=0.5):
super().__init__(fill_color=color, fill_opacity=0.9, stroke_color=color, stroke_opacity=1, stroke_width=3)
obj = Union(
Circle(radius=height/2).shift([-width/2+height/2,0,0]),
Rectangle(width=width-height,height=height),
Circle(radius=height/2).shift([+width/2-height/2,0,0]),
@uwezi
uwezi / 20260311_pixelate.py
Created March 11, 2026 14:47
[pixelate] Pixelate Mobjects in Manim. #manim #pil #image #pixel
from PIL.Image import Resampling
class doesthiswork2(Scene):
def construct(self):
vpixels = 40
svg = VGroup(
Circle(),
Text("Test")
)
oheight = svg.height
svg.scale_to_fit_height(8/(config.pixel_height/vpixels),scale_stroke=True)
@uwezi
uwezi / 20260218_manifold.py
Last active February 18, 2026 14:38
[Manifold3D and Manim] Using the manifold3D library within Manim. #manim #3D #manifold3D #csg
from manim import *
import manifold3d as mf3
class spherical(ThreeDScene):
def construct(self):
self.set_camera_orientation(phi=70 * DEGREES, theta=-70 * DEGREES)
sp = mf3.Manifold.sphere(radius =2, circular_segments=24)
verts = sp.to_mesh().vert_properties
manimsphere = VGroup(
@uwezi
uwezi / 20260128_meterclass.py
Created January 28, 2026 17:41
[Analog meter] A class object for analog meters. #manim #animation #electronics #class
from manim import*
class AnalogMeter(VGroup):
def __init__(self,
value = 0,
width=4,
height=3.5,
corner_radius=0.5,
outer_stroke_width=5,
outer_stroke_color=GRAY,
@uwezi
uwezi / 20260124_benzene.py
Last active January 24, 2026 13:35
[animated chemistry] Using special animations on chemical formulae. #manim #chemistry #transformbyglyphmap #chemfig #animation #tikz
from MF_Tools import TransformByGlyphMap
class benzeneAnim(Scene):
def construct(self):
mol1 = Tex(
r"\chemfig{*6(-=-=-=)}",
tex_template=myChemTemplate
).set_stroke(width=3)
mol2 = Tex(
r"\chemfig{*6(--=-(=O)-=)}",
tex_template=myChemTemplate