shapes

class janim.items.three_d.shapes.ParametricSurface(uv_func: Callable[[float, float], Vect], u_range: tuple[float, float] = (0, 1), v_range: tuple[float, float] = (0, 1), **kwargs)

Bases: SurfaceGeometry

Parametric Surface

Parameters:
  • uv_func – Parametric equation; it takes (u, v) as input and outputs the corresponding 3D coordinates

  • u_range – Range of values for the u variable

  • v_range – Range of values for the v variable

Example:

ParametricSurface(
    lambda u, v: [np.cos(u) * np.cos(v), np.cos(u) * np.sin(v), -u],
    u_range=[-PI, PI],
    v_range=[0, TAU],
    resolution=16,
).into('checker')
class janim.items.three_d.shapes.Sphere(center: Vect = array([0., 0., 0.]), radius: float = 1, u_range: tuple[float, float] = (0, 6.283185307179586), v_range: tuple[float, float] = (0, 3.141592653589793), **kwargs)

Bases: SurfaceGeometry

3D Sphere

Parameters:
  • center – Center of the sphere

  • radius – Radius of the sphere

  • u_range – Range of the u variable (i.e., values around the latitude, from 0 to TAU)

  • v_range – Range of the v variable (i.e., values along the longitude, with 0 at the bottom and PI at the top)

Example:

Sphere(radius=2).into('checker')
RESOLUTIONS: dict[str, Resolution] = {'face': (24, 12), 'smooth': (101, 51)}
class janim.items.three_d.shapes.Torus(major_radius: float = 3, minor_radius: float = 1, u_range: tuple[float, float] = (0, 6.283185307179586), v_range: tuple[float, float] = (0, 6.283185307179586), **kwargs)

Bases: SurfaceGeometry

3D Torus

Parameters:
  • major_radius – Major radius (distance from the center of the torus to the center of the tube)

  • minor_radius – Minor radius (radius of the tube)

  • u_range – Range of the u variable (along the major direction of the torus)

  • v_range – Range of the v variable (along the cross-section direction of the tube)

Example:

Torus(2.5, 0.6).into('checker')
RESOLUTIONS: dict[str, Resolution] = {'face': 24, 'smooth': 101}
class janim.items.three_d.shapes.Cylinder(radius: float = 1, height: float = 2, axis: Vect = array([0., 0., 1.]), u_range: tuple[float, float] = (0, 6.283185307179586), v_range: tuple[float, float] = (-0.5, 0.5), **kwargs)

Bases: SurfaceGeometry

3D Cylinder

Parameters:
  • radius – Radius of the cylinder

  • height – Height of the cylinder

  • axis – Direction vector of the cylinder axis (default along OUT)

  • u_range – Range of the u variable (angle around the cylindrical surface)

  • v_range – Range of the v variable (normalized values along the axis direction)

Example:

Cylinder(1, 3).into('checker')
RESOLUTIONS: dict[str, Resolution] = {'face': (24, 12), 'smooth': (101, 11)}
class janim.items.three_d.shapes.Cone(radius: float = 1, height: float = 1, axis: Vect = array([0., 0., 1.]), u_range: tuple[float, float] = (0, 6.283185307179586), v_min: float = 0, **kwargs)

Bases: SurfaceGeometry

3D Cone

Parameters:
  • radius – Radius of the base of the cone

  • height – Height of the cone

  • axis – Direction vector of the cone axis (default along OUT)

  • u_range – Range of the u variable (angle around the conical surface)

  • v_min – Minimum value of the v variable (used to crop the cone surface, 0 means starting from the cone tip)

Example:

Cone(1, 2).into('checker')
RESOLUTIONS: dict[str, Resolution] = {'face': (24, 12), 'smooth': (101, 11)}