Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20251220_mathtex.py
Last active December 20, 2025 16:13
[big expression] Finding and manipulating parts of a large LaTeX expression in LaTeX. #manim #mathtex #latex #indexlabels
from MF_Tools import ir
class bigeqn(Scene):
def construct(self):
eqn = MathTex(
r"""1+\sum_{i=1}^{2}\left\lfloor\left(
\frac{1}{\sum\limits_{j=1}^{i}\left\lfloor\left(\cos\left(\frac{(j-1)!\,+1}{j}\pi\right)^2\right)\right\rfloor}
\right)^\frac{1}{1}\right\rfloor"""
)
# uncomment for index labels
#self.add(eqn, index_labels(eqn[0]).set_color(RED))
@uwezi
uwezi / 20251211_newton.py
Last active December 11, 2025 21:38
[planetary orbit] Simulating a stable planetary orbit in Manim. #manim #astro #physics #updater #newton
class orbit(Scene):
def construct(self):
ax = Axes(
x_range=[-200e9,200e9,50e9],
y_range=[-200e9,200e9,50e9],
x_length=8,
y_length=8,
tips=False
)
G = 6.67e-11
@uwezi
uwezi / 20251210_glow.py
Last active December 10, 2025 18:48
[Glow effect] Adding a blurry copy of an object. #manim #glow #shadow #PIL #bitmap
from PIL import Image, ImageFilter
class Scene2(MovingCameraScene):
def construct(self):
def blur_image(mobjs, blur=15, bright=1.2, scale_first=1.2):
scene = Scene()
render = scene.renderer
objs = VGroup(*[m.copy().scale(scale_first, about_point=m.get_center()) for m in mobjs])
render.camera.set_pixel_array(np.zeros_like(render.camera.pixel_array))
render.camera.capture_mobjects(objs)
@uwezi
uwezi / 20251025_tikz.py
Last active October 27, 2025 16:16
[Tikz and XeLaTeX] Rednering Tikz code using XeLaTeX in Manim. #manim #latex #xelatex #dvisvgm #tikz
from manim import *
class tikztest(Scene):
def construct(self):
MyTexTemplate = TexTemplate(
tex_compiler="xelatex",
output_format=".xdv",
documentclass=r"\documentclass[preview,dvisvgm]{standalone}"
)
MyTexTemplate.add_to_preamble(r"\usepackage{tikz}")
@uwezi
uwezi / 20251015_linefrompoints.py
Last active October 15, 2025 18:22
[Line from points] Creating a line from a list of vertices. #manim #line #radius #rounded #tip
from manim import *
import manim.mobject.geometry.tips as tips
class LineFromPoints(Line):
def __init__(self, pointsdirections, radius=0, **kwargs):
super().__init__(**kwargs)
pointsradii = [(pointsdirections[0][0],0)]
for p0,p2 in zip(pointsdirections, pointsdirections[1:]):
if len(p0)==3:
r = p0[2]
@uwezi
uwezi / 20251015_linethroughpoints.py
Last active October 15, 2025 18:10
[Line through points] Creates a line through several points. #manim #line #rounded #tip #radius
class LineThroughPoints(Line):
def __init__(self, pointsdirections, radius=0, **kwargs):
super().__init__(**kwargs)
self.pointsdirections = pointsdirections
self.radius = radius
self.set_points([pointsdirections[0][0]])
for p0,p1 in zip(pointsdirections,pointsdirections[1:]):
dx,dy,dz = p1[0]-p0[0]
if len(p0) == 3:
r = p0[2]
@uwezi
uwezi / 20250606_npn.svg
Last active September 16, 2025 07:33
[NPN transistor] Current flows in a common-emitter NPN transistor. #manim #animation #physics #electronics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@uwezi
uwezi / 20250909_particles.py
Last active September 10, 2025 11:13
[particles in a box] Animation of particles inside a polygon with additional polygons on the inside. #manim #physics #dt #updater #intersection #collision
# https://discord.com/channels/581738731934056449/1414961601127383170/1415086069568766024
from manim import *
class dotinbox(Scene):
def construct(self):
outerbox = RegularPolygon(n=6).rotate(5*DEGREES).scale_to_fit_height(7)
innerobjs = VGroup(
RegularPolygon(n=5, fill_opacity=1).scale_to_fit_height(2).shift(UR),
Square(side_length=1).shift(DL)
)
@uwezi
uwezi / 20250823_fourier.py
Last active August 23, 2025 17:34
[Fourier epicycles] Drawing the outline of an SVG with epicycles. #manim #fft #svg #fourier
from manim import *
# inspired by Grant Sanderson's Fourier video
# translated to ManimCE and using numpy's FFT
class FFTCirclesDotScene(MovingCameraScene):
center_point = ORIGIN
slow_factor = 0.1
def get_fft_coefficients_of_path(self, path, n_samples=32768, n_freqs = 200):
@uwezi
uwezi / 20250823_possible.py
Last active August 23, 2025 11:35
[La Linea] Animation of a diamond breaking a sine wave. #manim #union #boolean
from manim import *
class possible2(Scene):
def construct(self):
phase = ValueTracker(0)
def bottom():
return VMobject().add_points_as_corners(
[
*[[x,0.5*np.sin(x-phase.get_value()),0] for x in np.linspace(-8,8,1000)],
[8,-8,0],[-8,-8,0],[-8,0,0]
]