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§
fn set_data(&mut self, data: &'a [P])
Sourcefn set_coefficient(&mut self, factor: &Self::CoefficientsType)
fn set_coefficient(&mut self, factor: &Self::CoefficientsType)
Set NB_COEFFICIENTS array.
Sourcefn get_coefficient(&self) -> Self::CoefficientsType
fn get_coefficient(&self) -> Self::CoefficientsType
Get NB_COEFFICIENTS array.
Sourcefn compute_point_to_model(p: P, coefficients: &Self::CoefficientsType) -> T
fn compute_point_to_model(p: P, coefficients: &Self::CoefficientsType) -> T
Return distance between target point and coefficients.
Sourcefn get_random_samples(&self) -> Self::SampleIdxType
fn get_random_samples(&self) -> Self::SampleIdxType
Get array of indices of samples.
Sourcefn compute_model_coefficients(
&self,
samples: &Self::SampleIdxType,
) -> Result<Self::CoefficientsType, String>
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§
Sourcefn get_random_sample_id(&self) -> Vec<usize>
fn get_random_sample_id(&self) -> Vec<usize>
Random numbers of indices by NB_SAMPLE.
Sourcefn get_distance_to_model(&self, coefficients: &Self::CoefficientsType) -> Vec<T>
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.
Sourcefn select_indices_within_tolerance(
&self,
coefficients: &Self::CoefficientsType,
tolerance: T,
) -> Vec<usize>
fn select_indices_within_tolerance( &self, coefficients: &Self::CoefficientsType, tolerance: T, ) -> Vec<usize>
Return indices of distance between point and coefficients smaller than tolerance.
Sourcefn count_indices_within_tolerance(
&self,
coefficients: &Self::CoefficientsType,
tolerance: T,
) -> usize
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.