normals¶
occulus.normals
¶
Surface normal estimation and orientation for point clouds.
Normal vectors are required for several downstream operations including Poisson surface reconstruction and point-to-plane ICP registration.
Available functions
- :func:
estimate_normals— PCA-based normal estimation from local neighbourhoods - :func:
orient_normals_to_viewpoint— flip normals to face a known viewpoint
All implementations use pure NumPy and SciPy. No optional dependencies required.
estimate_normals(cloud, *, radius=None, max_nn=30)
¶
Estimate surface normals via PCA on local neighbourhoods.
For each point, the max_nn nearest neighbours within radius are
collected and a PCA is performed. The eigenvector corresponding to the
smallest eigenvalue of the local covariance matrix is taken as the surface
normal. Normals are not oriented — use :func:orient_normals_to_viewpoint
to flip them toward a known viewpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. Returned cloud will have the |
required |
radius
|
float | None
|
Neighbourhood search radius. If |
None
|
max_nn
|
int
|
Maximum number of neighbours to use per point, by default 30. More neighbours → smoother normals. |
30
|
Returns:
| Type | Description |
|---|---|
PointCloud
|
A new cloud of the same concrete type with |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If the cloud has fewer than 3 points (PCA is not meaningful). |
Source code in src/occulus/normals/__init__.py
orient_normals_to_viewpoint(cloud, viewpoint)
¶
Flip normals so that they face a known viewpoint (scanner position).
A normal is flipped if the dot product with the vector from the point to the viewpoint is negative (i.e., the normal points away).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input cloud. Must have normals ( |
required |
viewpoint
|
NDArray[float64]
|
3D position of the viewpoint (e.g. scanner origin) as a (3,) array. |
required |
Returns:
| Type | Description |
|---|---|
PointCloud
|
A new cloud with consistently oriented normals. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If the cloud has no normals or |