SacModel

Trait SacModel 

Source
pub trait SacModel<'a, P: Copy, T: BasicFloat> {
    type SampleIdxType;
    type CoefficientsType;

    const NB_SAMPLE: usize;
    const NB_COEFFICIENTS: usize;

    // Required methods
    fn set_data(&mut self, data: &'a [P]);
    fn set_coefficient(&mut self, factor: &Self::CoefficientsType);
    fn get_coefficient(&self) -> Self::CoefficientsType;
    fn samples(&self) -> &[P];
    fn compute_point_to_model(p: P, coefficients: &Self::CoefficientsType) -> T;
    fn get_random_samples(&self) -> Self::SampleIdxType;
    fn compute_model_coefficients(
        &self,
        samples: &Self::SampleIdxType,
    ) -> Result<Self::CoefficientsType, String>;

    // Provided methods
    fn data_len(&self) -> usize { ... }
    fn get_random_sample_id(&self) -> Vec<usize> { ... }
    fn get_distance_to_model(
        &self,
        coefficients: &Self::CoefficientsType,
    ) -> Vec<T> { ... }
    fn select_indices_within_tolerance(
        &self,
        coefficients: &Self::CoefficientsType,
        tolerance: T,
    ) -> Vec<usize> { ... }
    fn count_indices_within_tolerance(
        &self,
        coefficients: &Self::CoefficientsType,
        tolerance: T,
    ) -> usize { ... }
}
Expand description

Represent any model.

Implement this to Customize model. Currently support SacModelPlane, SacModelSphere, SacModelLine, SacModelCircle3d

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn set_data(&mut self, data: &'a [P])

Source

fn set_coefficient(&mut self, factor: &Self::CoefficientsType)

Set NB_COEFFICIENTS array.

Source

fn get_coefficient(&self) -> Self::CoefficientsType

Get NB_COEFFICIENTS array.

Source

fn samples(&self) -> &[P]

Get random sample points.

Source

fn compute_point_to_model(p: P, coefficients: &Self::CoefficientsType) -> T

Return distance between target point and coefficients.

Source

fn get_random_samples(&self) -> Self::SampleIdxType

Get array of indices of samples.

Source

fn compute_model_coefficients( &self, samples: &Self::SampleIdxType, ) -> Result<Self::CoefficientsType, String>

Return CoefficientsType of samples.

§Err
  • Numbers of data smaller than NB_SAMPLE.
  • Samples could not be computed. (ex: samples are overlay or parallel each other.)

Provided Methods§

Source

fn data_len(&self) -> usize

Numbers of data

Source

fn get_random_sample_id(&self) -> Vec<usize>

Random numbers of indices by NB_SAMPLE.

Source

fn get_distance_to_model(&self, coefficients: &Self::CoefficientsType) -> Vec<T>

Returns a distance list and uses coefficients to calculate the distance from data to the model.

Source

fn select_indices_within_tolerance( &self, coefficients: &Self::CoefficientsType, tolerance: T, ) -> Vec<usize>

Return indices of distance between point and coefficients smaller than tolerance.

Source

fn count_indices_within_tolerance( &self, coefficients: &Self::CoefficientsType, tolerance: T, ) -> usize

Return numbers which between point and coefficients smaller than tolerance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, P, T: BasicFloat> SacModel<'a, P, T> for SacModelCircle3d<'a, P, T>
where P: Into<[T; 3]> + Clone + Copy,

Source§

impl<'a, P, T: BasicFloat> SacModel<'a, P, T> for SacModelLine<'a, P, T>
where P: Into<[T; 3]> + Clone + Copy,

Source§

impl<'a, P, T: BasicFloat> SacModel<'a, P, T> for SacModelPlane<'a, P, T>
where P: Into<[T; 3]> + Clone + Copy,

Source§

impl<'a, P, T: BasicFloat> SacModel<'a, P, T> for SacModelSphere<'a, P, T>
where P: Into<[T; 3]> + Clone + Copy,