Orbit

Orbit preview
remixableManimCE2DgravityKepler

manim/orbit_ellipse.py

"""Orbit: a light body running an ellipse around a heavy one at the focus.

Solved from Kepler's equation rather than integrated. A numerically
integrated orbit precesses a little every turn and never quite closes, and
an orbit that does not close cannot loop seamlessly; Kepler's equation
closes exactly and gives the right speed everywhere for free.

Render (the driver does this for every palette; these are for eyeballing):
    P=/opt/homebrew/opt/python@3.11/bin/python3.11
    ASSET_MODE=still  $P -m manim -s -t -r 1600,1600 manim/orbit_ellipse.py OrbitEllipse
    ASSET_MODE=motion $P -m manim -qh   -r 1080,1080 manim/orbit_ellipse.py OrbitEllipseLoop
"""

import numpy as np
from manim import (
    DOWN,

The full Manim source and the rendered video come with a plan.