This repo contains a few Manim Community scenes for Fourier/epicycle style animations, plus a reusable mobject FourierCircles.
fourier_manimCE.pyComplexWave(sum of cosines)FourierStandardFixed2(epicycles)PiecewiseExample
mobjects/fourier_circles.pyFourierCircles: reusable epicycle/circle-chain mobject
media/- Manim render outputs
Create and activate a virtualenv, then install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtNotes:
- Manim requires system dependencies (e.g. FFmpeg, LaTeX) depending on your scene.
- On macOS, you typically install FFmpeg via Homebrew:
brew install ffmpegFourierCircles takes a shape (path/Text/MathTex/SVG), samples it, computes Fourier coefficients, and draws an animated chain of circles + vectors.
from manim import *
from mobjects.fourier_circles import FourierCircles
class Demo(Scene):
def construct(self):
epicycles = FourierCircles(
input_graph=MathTex(r"\pi"),
vector_number=100,
n_samples=2000,
vector_type="arrow",
)
self.add(epicycles)
start_t = epicycles.vector_clock.get_value()
end_t = 2
self.play(
UpdateFromAlphaFunc(
epicycles,
lambda m, a, s=start_t, e=end_t: m.set_value(interpolate(s, e, a)),
),
run_time=10,
rate_func=linear,
)- VMobject/path with
point_from_proportion(custom paths) Text,Tex,MathTex(a subpath is automatically selected)- SVG file path or
SVGMobject
Examples:
FourierCircles(input_graph="high_clef.svg", vector_number=120)
FourierCircles(svg_file="high_clef.svg", vector_number=120)
FourierCircles(input_graph=SVGMobject("high_clef.svg"), vector_number=120)vector_type="line"orvector_type="arrow"
- Scale epicycle size:
scale_factor=...(aliassize=...) scales all coefficients. - Auto-fit (mainly for Text/MathTex):
auto_fit=True/Falsefit_fraction=0.7(default)fit_height=...,fit_width=...force_fit=True(force fit even for SVG/path inputs)
Use get_end() to trace the final tip:
trace = TracedPath(epicycles.get_end)
trace.set_stroke(YELLOW, 3)
self.add(trace)