Skip to main content

Module orient

Module orient 

Source
Expand description

Directions and frames read off a mesh.

Four questions a scan is asked before anything is fitted to it: which ways its flat faces face (face_directions), which axis its walls turn about (axis_of_revolution), along which axes its area spreads (principal_frame), and where it is open (open_rims).

Every answer is a computation over the triangles alone. The same mesh gives the same answer bit for bit on any thread count, and where two candidates tie they are told apart by where they point, never by the order they were found in.

§Face directions

Each triangle’s normal is smoothed over its neighbours, across the edges that are not creases, so a scan’s noise averages out within a face and never between two. The smoothed normals are binned on the sphere by area, a direction and its antipode in one bin, since a face and the face opposite it name one direction. Every bin holding more area than its neighbours seeds a search for the direction the area gathers at: the mean of the normals within the resolution, moved to and taken again until it stops moving. Those directions are kept by area, largest first: one within the resolution of a direction already kept is the same direction, and one is only kept where it holds more area within the resolution than in the ring from the resolution to three times it, the area of any direction already kept aside. A cylinder’s normals sweep a circle and put twice as much in that ring as within the resolution, so a cylinder gives no face direction, and a plane’s put none there.

A triangle then belongs to the kept direction its own normal or its smoothed one is nearest, where either is within the resolution. One whose own normal is within the resolution of the direction counts with it; one claimed by its smoothed normal alone counts where its own normal is within the Directions::cutoff of the face’s scatter. A scan’s noise scatters a face’s own normals past the resolution and the cutoff reaches out with them; an exact face’s do not scatter, and a fillet’s triangle that smoothing drew towards the face is left out. A face direction is the area-weighted mean of its triangles’ own normals, unsmoothed: exact where the faces are exact, and for a scan’s noise the mean that noise does not bias.

Structs§

Directions
How face_directions and axis_of_revolution read a mesh’s normals.
FaceDirection
A direction a mesh’s flat faces face.
Revolution
The axis a mesh’s walls turn about.
Rim
Where a mesh is open: a chain of edges each of which only one triangle uses.

Functions§

axis_of_revolution
The axis a mesh’s walls turn about, and the share of its area on them.
face_directions
The directions a mesh’s flat faces face, largest area first.
open_rims
The rims where a mesh is open, the largest vector area first.
principal_frame
The frame a mesh’s area spreads along: its origin at the area centroid, x along the greatest spread, y the next and z the least, from the second moments of the surface’s area, integrated exactly over each triangle.