fn rho_squared(distsq: f64, r: V3, n: V3) -> (f64, V3, V3) {
    debug_assert_eq!(distsq, r.sqnorm());
//    debug_assert_close!(1.0, n.sqnorm()); // untrue during numerical differentiation

    let dot = V3::dot(&r, &n);

    // rho^2 = ||r||^2 - (r dot n)^2
    let value = distsq - (dot * dot);
    let d_r = 2.0 * (r - n * dot);
    let d_n = -2.0 * r * dot;

    (value, d_r, d_n)
}
/// Calculate the square of the transverse distance given the distance squared,
/// the distance vector r, and one unit normal vector n
Calculate the square of the transverse distance given the distance squared,
the distance vector r, and one unit normal vector n
Calculate the square of the transverse distance given the distance squared the distance vector r and one unit normal vector n
fn rho_squared(distsq: f64, r: V3, n: V3) -> (f64, V3, V3) {
    debug_assert_eq!(distsq, r.sqnorm());
//    debug_assert_close!(1.0, n.sqnorm()); // untrue during numerical differentiation
    let dot = V3::dot(&r, &n);
    // rho^2 = ||r||^2 - (r dot n)^2
    let value = distsq - (dot * dot);
    let d_r = 2.0 * (r - n * dot);
    let d_n = -2.0 * r * dot;
    (value, d_r, d_n)
}
fn rho_squared ( distsq : f64 , r : V3 , n : V3 ) -> ( f64 , V3 , V3 ) { debug_assert_eq ! ( distsq r sqnorm ( ) ) ; //    debug_assert_close!(1.0, n.sqnorm()); // untrue during numerical differentiation let dot = V3 :: dot ( & r , & n ) ; // rho^2 = ||r||^2 - (r dot n)^2 let value = distsq - ( dot * dot ) ; let d_r = 2.0 * ( r - n * dot ) ; let d_n = - 2.0 * r * dot ; ( value , d_r , d_n ) }
Calculate the square of the transverse distance given the distance squared,
the distance vector r, and one unit normal vector n
Calculate the square of the transverse distance given the distance squared the distance vector r and one unit normal vector n
distsq
f64
r
V3
n
V3
distsq
f64
r
V3
n
V3