Document vertex ordering and box_corners format
This commit is contained in:
parent
f17667c93c
commit
8ccdcfffd7
2 changed files with 14 additions and 6 deletions
|
|
@ -32,6 +32,10 @@ uv pip install git+https://mpxd.net/code/jan/adze.git
|
||||||
## Documentation
|
## Documentation
|
||||||
Most functions and classes are documented inline.
|
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,
|
To read the inline help,
|
||||||
```python3
|
```python3
|
||||||
import adze
|
import adze
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ def build_tetrahedron(vertices: ArrayLike) -> poly_t:
|
||||||
Build a Schelegel-representation tetrahedron.
|
Build a Schelegel-representation tetrahedron.
|
||||||
|
|
||||||
Args:
|
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:
|
Returns:
|
||||||
Tetrahedron in Schelgel representation.
|
Tetrahedron in Schelgel representation.
|
||||||
|
|
@ -32,7 +33,8 @@ def build_box(box_corners: ArrayLike) -> poly_t:
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
box_corners: 2x3 array, representing the vertex coordinates of
|
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:
|
Returns:
|
||||||
Box in Schelgel representation.
|
Box in Schelgel representation.
|
||||||
|
|
@ -48,7 +50,7 @@ def build_box(box_corners: ArrayLike) -> poly_t:
|
||||||
[6, 3, 4],
|
[6, 3, 4],
|
||||||
]
|
]
|
||||||
|
|
||||||
box_corners = numpy.asarray(box_corners)
|
box_corners = numpy.asarray(box_corners, dtype=float)
|
||||||
vertices = [
|
vertices = [
|
||||||
[box_corners[0, 0], box_corners[0, 1], box_corners[0, 2]],
|
[box_corners[0, 0], box_corners[0, 1], box_corners[0, 2]],
|
||||||
[box_corners[1, 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:
|
Args:
|
||||||
box_corners: 2x3 array, representing the vertex coordinates of
|
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:
|
Returns:
|
||||||
List of planes, facing inwards.
|
List of planes, facing inwards.
|
||||||
"""
|
"""
|
||||||
box_corners = numpy.asarray(box_corners)
|
box_corners = numpy.asarray(box_corners, dtype=float)
|
||||||
faces = [
|
faces = [
|
||||||
(( 0, 0, 1), -box_corners[0, 2]),
|
(( 0, 0, 1), -box_corners[0, 2]),
|
||||||
(( 0, 0, -1), box_corners[1, 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.
|
Construct a list of planes corresponding to the faces of a tetrahedron.
|
||||||
|
|
||||||
Args:
|
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:
|
Returns:
|
||||||
List of planes, facing inwards.
|
List of planes, facing inwards.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue