Trait rust_examples::rsqrt::FastNormalize[][src]

pub trait FastNormalize {
    type NormVec;
    fn normalize(&self) -> Self::NormVec;
}
Expand description

This trait is a typeclass for all vectors that are normalized via a fast (approximate) inverse square root

Associated Types

Normalization return type

Required methods

Normalize this vector and return NormVec

Implementations on Foreign Types

Optimized implementation of FastNormalize for 3D vector of Floats.

In this implementation we know that Float is non-zero, not nan and not infinity, so the squares are always PositiveFloats. Therefore we can skip the checks on the components of the input vector.

Implementors

This implementation of FastNormalize uses a fast_rsqrt<1> to compute compute the invese square root of x^2 + y^2 + z^2 of the components of the initial vector.

Because the components must be converted to PositiveFloats, additional checks are necessary to validate the inputs. Moreover, because the validation might fail, the return type must be wrapped into an Option.