diff --git a/README.md b/README.md index 5fb61dc..f259368 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/adze/shapes.py b/adze/shapes.py index 0f2ae68..387152e 100644 --- a/adze/shapes.py +++ b/adze/shapes.py @@ -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.