Skip to main content

PointCloud

Struct PointCloud 

Source
pub struct PointCloud {
    pub points: Vec<[f64; 3]>,
    pub normals: Vec<[f64; 3]>,
    pub colors: Vec<[f32; 3]>,
}
Expand description

A collection of 3-D points with optional per-point normals and colors.

Fields§

§points: Vec<[f64; 3]>

XYZ positions.

§normals: Vec<[f64; 3]>

Per-point surface normals (may be empty).

§colors: Vec<[f32; 3]>

Per-point RGB colors in [0, 1] (may be empty).

Implementations§

Source§

impl PointCloud

Source

pub fn new() -> Self

Creates an empty point cloud.

Source

pub fn add_point(&mut self, p: [f64; 3])

Appends a point.

Source

pub fn len(&self) -> usize

Returns the number of points.

Source

pub fn is_empty(&self) -> bool

Returns true if the cloud is empty.

Source

pub fn bounding_box(&self) -> ([f64; 3], [f64; 3])

Returns the axis-aligned bounding box as (min, max).

Source

pub fn centroid(&self) -> [f64; 3]

Returns the centroid (mean position) of all points.

Source

pub fn translate(&mut self, offset: [f64; 3])

Translates all points by offset.

Source

pub fn scale_uniform(&mut self, s: f64)

Uniformly scales all points around the origin.

Source

pub fn from_grid( nx: usize, ny: usize, height_fn: impl Fn(f64, f64) -> f64, dx: f64, ) -> Self

Builds a height-field point cloud from a regular nx × ny grid.

Points are placed at (i * dx, j * dx, height_fn(i * dx, j * dx)).

Source§

impl PointCloud

Source

pub fn from_points(points: Vec<[f64; 3]>) -> Self

Constructs a PointCloud from a vec of points (expansion API).

Source

pub fn estimate_normals_pca(&mut self, k: usize)

Estimate per-point normals using PCA of the k nearest neighbors. Populates self.normals.

Source

pub fn voxel_downsample(&self, voxel_size: f64) -> Self

Return a new downsampled cloud using a voxel grid of side voxel_size.

Source

pub fn statistical_outlier_removal(&self, k: usize, std_ratio: f64) -> Self

Return a new cloud with statistical outliers removed.

Source§

impl PointCloud

Source

pub fn farthest_point_sample(&self, k: usize) -> Self

Farthest Point Sampling: select k well-spread points from this cloud.

Returns a new PointCloud with the selected points (normals / colors are copied if present).

Source

pub fn fit_plane_ransac( &self, n_iter: usize, threshold: f64, ) -> Option<RansacPlaneResult>

Fit a plane to the point cloud using RANSAC.

Returns None if fewer than 3 points are present.

Source

pub fn pca_obb(&self) -> ([[f64; 3]; 3], [f64; 3], [f64; 3])

Compute the PCA-based OBB of this cloud.

Returns (principal_axes, half_extents, center).

Source

pub fn compute_principal_curvatures(&self, k: usize) -> Vec<(f64, f64)>

Compute PCA-based principal curvatures for each point.

For each point a k-NN neighbourhood is gathered, the 3×3 covariance matrix is formed, and the two smallest eigenvalues (λ₁ ≤ λ₂) are returned as the approximate principal curvatures κ₁ and κ₂.

Returns a Vec<(f64, f64)> of (kappa1, kappa2) for every point.

Source

pub fn icp_register(&self, target: &PointCloud) -> IcpResult

Align this cloud onto target using ICP (point-to-point) and return the registration result (rotation + translation + error).

Calls the existing IcpRegistration::align helper.

Trait Implementations§

Source§

impl Default for PointCloud

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.