[−][src]Function norman::normalized
pub fn normalized<T: Norm<D, Output = R> + Div<R, Output = T>, D, R: Num>(
v: T,
desc: D
) -> T
Returns the normalization of v
according to the norm desc
,
i.e. v
divided by its norm.
Attention
Due to numerical errors, the result is not guaranteed to have exactly norm 1
after calling this function.
On integer types this function will do complete nonsense since
Div
is implemented as an integer division for integers.
Example
use norman::normalized; use norman::desc::Abs; assert_eq!(normalized( 0.25f32, Abs::new()), 1.0); assert_eq!(normalized(-3.00f32, Abs::new()), -1.0);