/// Differential of the function that produces a unit vector.
///
/// Format of the output derivative (a Jacobian) is declared above.
Differential of the function that produces a unit vector.
Format of the output derivative (a Jacobian) is declared above.
Differential of the function that produces a unit vector . Format of the output derivative ( a Jacobian ) is declared above .
pub fn unit(vec: V3) -> (V3, M33) {
        // (expression for gradient optimized by hand on paper)
        let norm = vec.norm();
        let unit = vec / norm;
        let outer_product = M3(unit.map(|x| x * unit).0);
        let grad = norm.recip() * (M33::eye() - outer_product);
        (unit, grad)
    }
pub fn unit ( vec : V3 ) -> ( V3 , M33 ) { // (expression for gradient optimized by hand on paper) let norm = vec . norm ( ) ; let unit = vec / norm ; let outer_product = M3 ( unit . map ( | x | x * unit ) . 0 ) ; let grad = norm . recip ( ) * ( M33 :: eye ( ) - outer_product ) ; ( unit , grad ) }
Differential of the function that produces a unit vector.
Differential of the function that produces a unit vector .
vec
V3