Trait geomath::prelude::Metric [−][src]
pub trait Metric where
Self: Copy, {
fn dot(&self, other: &Self) -> f64;
fn distance2(&self, other: &Self) -> f64;
fn distance(&self, other: &Self) -> f64;
fn magnitude2(&self) -> f64;
fn magnitude(&self) -> f64;
fn set_normalized(&mut self) -> &mut Self;
fn normalized(&self) -> Self { ... }
}
Expand description
Operations between objects of a metric space
A metric space is considered as a space where it exists a norm based on dot product. It can be the metric operations between two vectors or matrices such as the distance or the magnitude.
Note : For matrices and vectors you can also use operators : %
for distance, |
for dot product, !
for magnitude
Required methods
fn magnitude2(&self) -> f64
fn magnitude2(&self) -> f64
Squared magnitude of an object
fn set_normalized(&mut self) -> &mut Self
fn set_normalized(&mut self) -> &mut Self
Normalizes the vector, ie. sets magnitude to 1 without changing direction
Provided methods
fn normalized(&self) -> Self
fn normalized(&self) -> Self
Get the normalized vector, ie. vector with same direction and magnitude 1