pub fn point_point_distance(a: &[f64], b: &[f64]) -> Result<f64, StrError> {
    let ndim = a.len();
    if ndim < 2 || ndim > 3 {
        return Err("a.len() == ndim must be 2 or 3");
    }
    if b.len() != ndim {
        return Err("b.len() must equal a.len() == ndim");
    }
    let distance: f64;
    if ndim == 2 {
        distance = f64::sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]));
    } else {
        distance =
            f64::sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]) + (b[2] - a[2]) * (b[2] - a[2]));
    }
    Ok(distance)
}
/// Computes the point-to-point distance
///
/// # Input
///
/// * `a` -- first point
/// * `b` -- second point
///
/// # Output
///
/// Returns the unsigned distance between the two points.
///
/// # Examples
///
/// ```
/// use gemlab::geometry::point_point_distance;
/// use gemlab::StrError;
/// use gemlab::util::SQRT_2;
/// use russell_chk::assert_approx_eq;
///
/// fn main() -> Result<(), StrError> {
///     let d = point_point_distance(&[0.0, 0.0], &[1.0, 1.0])?;
///     assert_approx_eq!(d, SQRT_2, 1e-15);
///     Ok(())
/// }
/// ```
Computes the point-to-point distance
Computes the point - to - point distance
pub fn point_point_distance(a: &[f64], b: &[f64]) -> Result<f64, StrError> {
    let ndim = a.len();
    if ndim < 2 || ndim > 3 {
        return Err("a.len() == ndim must be 2 or 3");
    }
    if b.len() != ndim {
        return Err("b.len() must equal a.len() == ndim");
    }
    let distance: f64;
    if ndim == 2 {
        distance = f64::sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]));
    } else {
        distance =
            f64::sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]) + (b[2] - a[2]) * (b[2] - a[2]));
    }
    Ok(distance)
}
pub fn point_point_distance ( a : & [ f64 ] , b : & [ f64 ] ) -> Result < f64 , StrError > { let ndim = a . len ( ) ; if ndim < 2 || ndim > 3 { return Err ( " " ) ; } if b . len ( ) != ndim { return Err ( " " ) ; } let distance : f64 ; if ndim == 2 { distance = f64 :: sqrt ( ( b [ 0 ] - a [ 0 ] ) * ( b [ 0 ] - a [ 0 ] ) + ( b [ 1 ] - a [ 1 ] ) * ( b [ 1 ] - a [ 1 ] ) ) ; } else { distance = f64 :: sqrt ( ( b [ 0 ] - a [ 0 ] ) * ( b [ 0 ] - a [ 0 ] ) + ( b [ 1 ] - a [ 1 ] ) * ( b [ 1 ] - a [ 1 ] ) + ( b [ 2 ] - a [ 2 ] ) * ( b [ 2 ] - a [ 2 ] ) ) ; } Ok ( distance ) }
Computes the point-to-point distance
Computes the point - to - point distance
a
&[f64]
b
&[f64]
a
&[f64]
b
&[f64]
input
`a` -- first point
`b` -- second point
` a ` -- first point ` b ` -- second point
output
Returns the unsigned distance between the two points.
Returns the unsigned distance between the two points .
examples
None