Document vertex ordering and box_corners format

This commit is contained in:
Jan Petykiewicz 2026-04-01 19:20:00 -07:00
commit 8ccdcfffd7
2 changed files with 14 additions and 6 deletions

View file

@ -32,6 +32,10 @@ uv pip install git+https://mpxd.net/code/jan/adze.git
## Documentation
Most functions and classes are documented inline.
Geometry helper input contracts:
- `build_tetrahedron()` and `planes_from_tetrahedron()` expect tetrahedron vertices in the helper's documented positive winding.
- `build_box()` and `planes_from_box()` expect `box_corners[0]` to be the per-axis minimum and `box_corners[1]` the per-axis maximum.
To read the inline help,
```python3
import adze

View file

@ -10,7 +10,8 @@ def build_tetrahedron(vertices: ArrayLike) -> poly_t:
Build a Schelegel-representation tetrahedron.
Args:
vertices: 4x3 array, representing the vertex coordinates.
vertices: 4x3 array, representing the vertex coordinates. Vertices must
be ordered with the positive winding expected by this helper.
Returns:
Tetrahedron in Schelgel representation.
@ -32,7 +33,8 @@ def build_box(box_corners: ArrayLike) -> poly_t:
Args:
box_corners: 2x3 array, representing the vertex coordinates of
two diagonally-opposite corners of the box.
two diagonally-opposite corners of the box. `box_corners[0]` must be
the per-axis minimum corner and `box_corners[1]` the per-axis maximum.
Returns:
Box in Schelgel representation.
@ -48,7 +50,7 @@ def build_box(box_corners: ArrayLike) -> poly_t:
[6, 3, 4],
]
box_corners = numpy.asarray(box_corners)
box_corners = numpy.asarray(box_corners, dtype=float)
vertices = [
[box_corners[0, 0], box_corners[0, 1], box_corners[0, 2]],
[box_corners[1, 0], box_corners[0, 1], box_corners[0, 2]],
@ -72,12 +74,13 @@ def planes_from_box(box_corners: ArrayLike) -> list[plane_t]:
Args:
box_corners: 2x3 array, representing the vertex coordinates of
two diagonally-opposite corners of the box.
two diagonally-opposite corners of the box. `box_corners[0]` must be
the per-axis minimum corner and `box_corners[1]` the per-axis maximum.
Returns:
List of planes, facing inwards.
"""
box_corners = numpy.asarray(box_corners)
box_corners = numpy.asarray(box_corners, dtype=float)
faces = [
(( 0, 0, 1), -box_corners[0, 2]),
(( 0, 0, -1), box_corners[1, 2]),
@ -95,7 +98,8 @@ def planes_from_tetrahedron(vertices: ArrayLike) -> list[plane_t]:
Construct a list of planes corresponding to the faces of a tetrahedron.
Args:
vertices: 4x3 array, representing the vertex coordinates.
vertices: 4x3 array, representing the vertex coordinates. Vertices must
be ordered with the positive winding expected by this helper.
Returns:
List of planes, facing inwards.