Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@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)
@uwezi
uwezi / 20231110_dudewaldo_glyphmap.py
Created September 9, 2024 18:24
[TransformByGlyphMap] Code by dudewaldo4 on Discord. #manim #mathtex #transform #TransformByGlyphMap
# https://discord.com/channels/581738731934056449/976376734935048223/1161709114154569819
# https://www.youtube.com/watch?v=Bg999qefIic
def ir(a,b): # inclusive range, useful for TransformByGlyphMap
return list(range(a,b+1))
class TransformByGlyphMap(AnimationGroup):
def __init__(self, mobA, mobB, *glyph_map, replace=True, from_copy=False, show_indices=False, **kwargs):
# replace=False does not work properly
@uwezi
uwezi / 20240904_area_02.py
Last active September 4, 2024 19:19
[area to y-axis] Get the area between y-axis and curve. #manim #plot #area #axes
from manim import *
# https://discord.com/channels/581738731934056449/753938743366254642/1280965870239223920
class Test(Scene):
def construct(self):
ax1 = Axes(
x_range=[-1, 7, 10],
y_range=[0, 6, 10],
x_length=6,
y_length=5
).add_coordinates()
@uwezi
uwezi / 20240904_area_1.py
Last active September 4, 2024 19:16
[area to y-axis] Get the area between a curve and y-axis. #manim #plot #area #axes
from manim import *
# https://discord.com/channels/581738731934056449/753938743366254642/1280962332469624953
class Test(Scene):
def construct(self):
ax1 = Axes(
x_range=[-1, 7, 10],
y_range=[0, 6, 10],
x_length=6,
y_length=5
).add_coordinates()
@uwezi
uwezi / 20240901_lambda_plot.py
Created September 1, 2024 22:00
[lambda plot] comparing functions and lambda functions. #manim #plot #axes #lambda #function
from manim import *
class plotter(Scene):
def construct(self):
def func(x):
return 2*np.sin(x)
ax = Axes()
pl1 = ax.plot(func)
pl2 = ax.plot(
lambda x: 2*np.cos(x)
@uwezi
uwezi / 20240901_always.py
Last active September 1, 2024 22:00
[always lambda] comparing functions and lambda functions. #manim #lambda #always_redraw #valuetracker
from manim import *
class circles(Scene):
def construct(self):
vt = ValueTracker(1)
def mobfunc():
return Circle(radius=vt.get_value(), color=BLUE).shift(3*LEFT)
circ1 = always_redraw(mobfunc)
circ2 = always_redraw(lambda:
@uwezi
uwezi / 20240809_cplxnumber.py
Last active August 9, 2024 11:10
[Displaying dynamic complex numbers] Displaying complex numbers from value trackers. #manim #decimalnumber #complexnumber #animation #complexvaluetracker #valuetracker
# https://discord.com/channels/581738731934056449/1271400215525724162/1271400215525724162
from manim import *
class cplxNumber(Scene):
def construct(self):
ax = ComplexPlane().add_coordinates()
self.add(ax)
ctr = ComplexValueTracker(1+1j)
cdisp = always_redraw(lambda:
VGroup(