pub trait Metric {
// Required methods
fn distance_squared(&self, other: &Self) -> f64;
fn n_dimensions(&self) -> usize;
fn distance(&self, other: &Self) -> f64;
}Expand description
Operates on elements on a metric space.
Metric implements a distance metric between points.
Required Methods§
Sourcefn distance_squared(&self, other: &Self) -> f64
fn distance_squared(&self, other: &Self) -> f64
Compute the squared distance between two vectors belonging to a metric space.
§Example
use hoomd_vector::{Cartesian, Metric};
let x = Cartesian::from([0.0, 1.0, 1.0]);
let y = Cartesian::from([1.0, 0.0, 0.0]);
assert_eq!(3.0, x.distance_squared(&y));Sourcefn n_dimensions(&self) -> usize
fn n_dimensions(&self) -> usize
Return the number of dimensions in this vector space.
§Example
use hoomd_vector::{Cartesian, Metric};
let vec2 = Cartesian::<2>::default();
let vec3 = Cartesian::<3>::default();
assert_eq!(2, vec2.n_dimensions());
assert_eq!(3, vec3.n_dimensions());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.