FloatVector

Trait FloatVector 

Source
pub trait FloatVector<T>: Vector<T>
where T: FloatScalar,
{ // Required methods fn length(&self) -> T; fn normalize(&self) -> Self; fn distance(l: &Self, r: &Self) -> T; }
Expand description

Trait for vectors with floating-point components.

Extends the base Vector trait with operations that require floating-point arithmetic, such as length calculation and normalization.

Required Methods§

Source

fn length(&self) -> T

Computes the Euclidean length (magnitude) of the vector.

For vector v:

||v|| = √(v₁² + v₂² + ... + vₙ²)
Source

fn normalize(&self) -> Self

Returns a unit vector in the same direction.

For vector v:

v̂ = v / ||v||
§Note

Returns NaN or Inf components if the vector has zero length.

Source

fn distance(l: &Self, r: &Self) -> T

Computes the Euclidean distance between two vectors.

For vectors v and w:

d(v, w) = ||v - w||

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<T> FloatVector<T> for Vector2<T>
where T: FloatScalar,

Source§

impl<T> FloatVector<T> for Vector3<T>
where T: FloatScalar,

Source§

impl<T> FloatVector<T> for Vector4<T>
where T: FloatScalar,