diff --git a/README.md b/README.md index f131432..5fb61dc 100644 --- a/README.md +++ b/README.md @@ -6,28 +6,27 @@ **Homepage:** https://mpxd.net/code/jan/adze **Capabilities:** - - Clipping or splitting arbitrary polyhedra - - by a plane or a collection of planes (i.e. a convex polyhedron) - - Voxelizing arbitrary polyhedra - - + - Clipping or splitting arbitrary polyhedra by a plane or a collection of planes (i.e. a convex polyhedron). + - Accurate anti-aliased voxelization of arbitrary polyhedra on non-uniform rectangular grids. + - Calculation of polynomial moments (volume, centroid, inertia, etc.) for clipped polyhedra. ## Installation **Dependencies:** -* python 3.6 or newer +* python 3.11 or newer * numpy * pytest (optional, testing) * pytest-benchmark (optional, benchmarking) Install with pip from PyPi (preferred): ```bash -pip3 install adze +pip install adze ``` Install directly from git repository: ```bash -pip3 install git+https://mpxd.net/code/jan/adze.git@release +uv pip install git+https://mpxd.net/code/jan/adze.git ``` ## Documentation diff --git a/adze/__init__.py b/adze/__init__.py index 76b138e..b3575bd 100644 --- a/adze/__init__.py +++ b/adze/__init__.py @@ -38,18 +38,28 @@ Helper functions include -------------------------- -In the polyhedron representation returned by the build_* functions and accepted by - most other functions (split, clip, get_volume, get_moments, voxelize), the - polyhedron is stored as a 3-vertex-connected, triply-linked graph, with each vertex's - neighbors listed in counterclockwise order when viewed from outside the polyhedron. TODO - Each graph-vertex (g-vertex) is connected to exactly 3 other g-vertices; polygon- - vertices (p-vertices) are +### Internal Representation: The Schlegel Diagram +adze represents 3D shapes (polyhedra) using a specialized graph called a Schlegel +diagram. This format is designed for high-performance geometric calculations. - TODO - This representation looks like - poly = {'neighbors': ndarray[Px3, int], 'vertices': ndarray[Px3, float]} - where poly['neighbors'] contains +#### Key Features: +- **Exactly Three Neighbors:** Every vertex in the graph is connected to exactly + three other vertices. This "3-regular" property makes algorithms for clipping and + splitting shapes much simpler and more robust. +- **Ordered Adjacency:** For each vertex, the three neighbors are listed in + counter-clockwise order when viewed from outside the shape. This order defines + the "orientation" of the shape's surfaces. +- **Handling Complex Corners:** In real-world shapes, a corner (vertex) might have + more than three edges meeting (e.g., the tip of a pyramid). adze handles this by + creating multiple "copy" vertices at the same physical location, each handling + part of the original corner's connectivity. + +#### Data Structure: +Shapes are stored as a dictionary containing two NumPy arrays: +- `poly['vertices']`: An `[N x 3]` array of float coordinates (X, Y, Z). +- `poly['neighbors']`: An `[N x 3]` array of integer indices. + `poly['neighbors'][i, :]` contains the indices of the 3 vertices connected to vertex `i`. """