Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active August 9, 2024 11:10
Show Gist options
  • Save uwezi/e790d12e04c64f6d24b9fcddbb882e1d to your computer and use it in GitHub Desktop.
Save uwezi/e790d12e04c64f6d24b9fcddbb882e1d to your computer and use it in GitHub Desktop.
[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(
DecimalNumber(number=ctr.get_value().real),
DecimalNumber(number=ctr.get_value().imag, unit="i", include_sign=True)
).arrange(RIGHT,buff=0.1).to_corner(UR).add_background_rectangle()
)
dot = always_redraw(lambda:
Dot(point=ax.n2p(ctr.get_value()), color=YELLOW)
)
self.add(cdisp,dot)
self.wait()
for _ in range(5):
self.play(ctr.animate.set_value(np.random.uniform(-6,6)+1j*np.random.uniform(-3,3)))
self.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment