Shape kernels compare 3D point clouds of any size, with no correspondence between points: Chamfer, Hausdorff, Wasserstein-Procrustes, and Gromov-Wasserstein.
Each cloud is packed once, centered and rotated onto its principal axes, and every kernel scores a list of row packs against a list of column packs.
Packs are built one cloud at a time, so a caller passes whatever packs it holds as an array of pointers.
A pack is opaque: nk_shapes_packed_shape_* reads its points, centroid, principal frame as a quaternion, scale, descending spreads, and largest radius, and nk_shapes_unpack_* restores its cloud.
The spreads and radius bound Wasserstein-Procrustes and Hausdorff from below for free, the way vector norms bound dot products.
Gromov-Wasserstein and Wasserstein-Procrustes take a caller’s workspace, since a transport plan depends on both clouds and fits in neither pack.
nk_shapes_pack_normalized_* takes the same arguments and also divides each cloud by its RMS distance from the centroid, which it keeps as the scale, so every kind ignores size as well as pose.
Each kind compares the packed coordinates, so mixing absolute and normalized packs in one call is the caller’s choice.
Between normalized packs, a rotation takes column cloud b onto row cloud a as aᵢ ≈ (scale_a / scale_b) × R × (bⱼ − b̄) + ā.
In C++, nk::shapes_packed owns many packs in one allocation and exposes the pointer array, and make_normalized packs them normalized:
template <shapes_dtype value_type_,
typename allocator_type_ = aligned_allocator<char>>
class shapes_packed
One allocation holds the table of pack pointers, then the packs back to back, each on an nk_default_alignment_k boundary, so data() passes straight to every shape kernel.
allocator_typeThe allocator of the packs' one block, which uses-allocator construction looks up.
Packs every cloud like make, through one backend's kernels instead of a capability mask, such as nk_shapes_pack_size_f32_serial and nk_shapes_pack_f32_serial.
Parameters
clouds
in
The point clouds to pack, one pack per cloud.
alloc
in
Source of the packs' blocks.
capabilities
in
Capabilities to pack with; measure with the same ones.
pack_size
in
Measures one pack; pair it with pack.
pack
in
Packs one cloud on the CPU, with a null stream; a normalized one packs like make_normalized.
At least shapes_pack_size bytes, aligned to nk_default_alignment_k.
capabilities
in
Capabilities to pick from, or zero for the template in math_type_.
stream
in
Null on the CPU, or the stream of the device capabilities describes.
shapes_pack_normalizedPacks one cloud like shapes_pack, also dividing it by its RMS distance from the centroid, which the pack keeps as its scale, or by 1 when the cloud has no spread.
The [rows,columns] distances, results_stride bytes apart.
results_stride
in
Bytes between the rows of results.
rotations
out
Null, or the [rows,columns,3,3] rotations taking each column cloud onto each row cloud through the centroids.
limit
in
Distances up to it are exact; past it, a pair may stop early and report a lower bound that also lies past it, with that bound's flip in rotations. Infinity scores all.
capabilities
in
Capabilities to pick from, or 0 for the template in distance_type_.
stream
in
Null on the CPU, or the stream of the device capabilities describes.
chamfers_packedChamfer distances between every row pack and every column pack, the best of 8 axis flips.
The [rows,columns] distances, results_stride bytes apart.
results_stride
in
Bytes between the rows of results.
rotations
out
Null, or the [rows,columns,3,3] rotations taking each column cloud onto each row cloud through the centroids.
limit
in
Distances up to it are exact; past it, a pair may stop early and report a lower bound that also lies past it, with that bound's flip in rotations. Infinity scores all.
Capabilities to pick from, or 0 for the template in distance_type_.
wassersteinprocrustes_workspace_sizeReturns the workspace bytes of wassersteinprocrustes_packed between clouds of up to row_points and column_points points.
The [rows,columns] distances, results_stride bytes apart.
results_stride
in
Bytes between the rows of results.
rotations
out
Null, or the [rows,columns,3,3] rotations taking each column cloud onto each row cloud through the centroids.
workspace
in
Scratch aligned to nk_default_alignment_k, of what wassersteinprocrustes_workspace_size reports for the largest clouds, with the same capabilities and distance_type_, or more.
capabilities
in
Capabilities to pick from, or 0 for the template in distance_type_.
stream
in
Null on the CPU, or the stream of the device capabilities describes.