shapes_3d¶
The 3-D shapes, in two families.
Curved shapes – Sphere, Cylinder, Cone,
Torus, and Dot3D / Line3D / Arrow3D built
from them – are Surface subclasses. They
carry an analytic coordinate function and a normal function, and are tessellated
per frame to whatever the camera needs, so they stay smooth as you move in.
Faceted shapes – Polyhedron and everything built on it:
Prism, Cube, the Platonic solids, ConvexHull3D – are
defined by explicit vertices and flat polygon faces. Their faces are already
planar, so they are triangulated once at construction and never refined.
The revolved solids share one vocabulary: radius, u_range / v_range
and closed, with direction defaulting to UP on both Cone
and Cylinder. Manim’s spellings of those (base_radius,
show_base, show_ends, u_min, checkerboard_colors) raise here,
naming the Algan one; they are correct under algan.manim, where Manim’s
classes live. resolution is the one
Manim name kept, counting patches rather than vertices as Manim does, and
u_range / v_range keep Manim’s names but take Algan’s degrees.
Unlike 2-D shapes, these respond to light. See Your First 3-D Scene.
Classes
A circular cone, tessellated from a |
|
The convex hull of a point cloud, as a flat-faced |
|
A cube -- a |
|
A cylinder, tessellated from a |
|
The twelve-faced Platonic solid, built from flat pentagonal faces. |
|
A small |
|
The twenty-faced Platonic solid, built from flat triangular faces. |
|
A thin capped |
|
The eight-faced Platonic solid, built from flat triangular faces. |
|
A solid built from explicit vertices and indexed polygon faces. |
|
A right rectangular prism -- a box -- built from six flat faces. |
|
A 3-D sphere, tessellated from a |
|
The four-faced Platonic solid, built from flat triangular faces. |
|
A torus, tessellated from a |
Functions
- orient_faces_outward(vertex_coords, faces_list)[source]¶
Rewind a closed polyhedron’s faces so every one of them faces outward.
Returns a new face list, or the input unchanged when the mesh is not a closed orientable manifold and the question therefore has no answer.
Two steps, both standard. First make the winding CONSISTENT: two faces that agree on their orientation traverse their shared edge in opposite directions, so a flood fill over the shared-edge graph flips whichever neighbour disagrees. Then fix the global sign, which consistency alone cannot: the signed volume of the closed shell (the divergence theorem, one tetrahedron per triangle of the fan) is positive exactly when the faces point outward, so a negative total flips all of them.
It bails out, leaving the input alone, on anything that is not a closed orientable manifold – an undirected edge used by other than two faces (an open mesh, a T-junction, a non-manifold fin), a flood fill that reaches a face two ways with contradicting orientations (a Moebius-like shell), a shell in more than one connected piece, or a degenerate zero volume. A
Polyhedronis public API and takes arbitrary user geometry, so the pass has to be a no-op wherever “outward” is not defined rather than guess.Why this exists: the projected winding sign IS the renderer’s backface bit (
raster_taichi._AA_BACKFACE_BIT), which is what separates the near and far sheets of a closed mesh for the analytic-AA run rule. The face lists Algan ships for the Platonic solids are Manim’s, and they are not consistently oriented – 12 of anIcosahedron’s 20 faces, 2 of 4 on aTetrahedron, 2 of 8 on anOctahedron, 3 of 12 on aDodecahedron, 0 of 6 on aCube. Seerendering/raytracing/DESIGN_mesh_identity.mdss6.5.