Skip to content

orbits

Orbit visualization helpers for viser.

These utilities are intentionally lightweight and composable:

  • Static primitives to draw circular orbit rings in the XY plane
  • A convenience server builder for Hohmann-transfer-like trajectories, which overlays two circular orbits and animates the transfer trajectory.

add_circular_orbit(server: viser.ViserServer, radius: float, *, name: str, center: Sequence[float] = (0.0, 0.0, 0.0), plane: Literal['xy'] = 'xy', n_points: int = 256, color: tuple[int, int, int] = (200, 200, 200), line_width: float = 2.0) -> viser.LineSegmentsHandle

Add a static circular orbit ring.

Currently supports only the XY plane (common for planar problems).

Source code in openscvx/plotting/viser/orbits.py
def add_circular_orbit(
    server: viser.ViserServer,
    radius: float,
    *,
    name: str,
    center: Sequence[float] = (0.0, 0.0, 0.0),
    plane: Literal["xy"] = "xy",
    n_points: int = 256,
    color: tuple[int, int, int] = (200, 200, 200),
    line_width: float = 2.0,
) -> viser.LineSegmentsHandle:
    """Add a static circular orbit ring.

    Currently supports only the XY plane (common for planar problems).
    """
    if plane != "xy":
        raise NotImplementedError("Only plane='xy' is currently supported")
    pts = _circle_points_xy(radius, center=center, n_points=n_points)
    segs = _line_segments_closed(pts)
    return server.scene.add_line_segments(
        f"/orbits/{name}",
        points=segs,
        colors=color,
        line_width=line_width,
    )