Trait nalgebra::Norm [] [src]

pub trait Norm: Sized {
    type NormType: BaseFloat;
    fn norm_squared(&self) -> Self::NormType;
    fn normalize(&self) -> Self;
    fn normalize_mut(&mut self) -> Self::NormType;
    fn try_normalize(&self, min_norm: Self::NormType) -> Option<Self>;
    fn try_normalize_mut(&mut self, min_norm: Self::NormType) -> Option<Self::NormType>;

    fn norm(&self) -> Self::NormType { ... }
}

Traits of objects having an euclidian norm.

Associated Types

type NormType: BaseFloat

The scalar type for the norm (i.e. the undelying field).

Required Methods

fn norm_squared(&self) -> Self::NormType

Computes the squared norm of self.

This is usually faster than computing the norm itself.

fn normalize(&self) -> Self

Gets the normalized version of a copy of v.

Might return an invalid result if the vector is zero or close to zero.

fn normalize_mut(&mut self) -> Self::NormType

Normalizes self.

The result might be invalid if the vector is zero or close to zero.

fn try_normalize(&self, min_norm: Self::NormType) -> Option<Self>

Gets the normalized version of a copy of v or None if the vector has a norm smaller or equal to min_norm. In particular, .try_normalize(0.0) returns None if the norm is exactly zero.

fn try_normalize_mut(&mut self, min_norm: Self::NormType) -> Option<Self::NormType>

Normalized v or does nothing if the vector has a norm smaller or equal to min_norm.

Returns the old norm or None if the normalization failed.

Provided Methods

fn norm(&self) -> Self::NormType

Computes the norm of self.

Implementors