pub fn point_cylinder_distance(a: &[f64], b: &[f64], radius: f64, p: &[f64]) -> Result<f64, StrError> {
    let ndim = a.len();
    if ndim != 3 {
        return Err("axis_a.len() == ndim must be 3");
    }
    if b.len() != ndim {
        return Err("axis_b.len() must equal center.len() == ndim");
    }
    if p.len() != ndim {
        return Err("p.len() must equal center.len() == ndim");
    }
    let center_distance = point_line_distance(a, b, p)?;
    let distance = center_distance - radius;
    Ok(distance)
}
/// Computes the signed distance from point to the surface of a cylinder parallel to x
///
/// # Input
///
/// `a` -- First 3D point on the cylinder axis
/// `b` -- Second 3D point on the cylinder axis (must be different than `a`)
/// `radius` -- cylinder radius
/// `p` -- 3D point
///
/// # Output
///
/// Returns the signed distance (negative is inside)
///
/// # Note
///
/// This works in 3D only.
///
/// # Examples
///
/// ```
/// use gemlab::geometry::point_cylinder_distance;
/// use gemlab::StrError;
/// use gemlab::util::{SQRT_2, SQRT_3};
/// use russell_chk::assert_approx_eq;
///
/// fn main() -> Result<(), StrError> {
///     let a = &[-10.0, -10.0, -10.0];
///     let b = &[100.0, 100.0, 100.0];
///     let radius = 5.0;
///     let d = point_cylinder_distance(a, b, radius, &[0.0, 0.0, 0.0])?;
///     assert_eq!(d, -radius);
///
///     let d = point_cylinder_distance(a, b, radius, &[1.0, 1.0, 0.0])?;
///     assert_approx_eq!(d, SQRT_2 / SQRT_3 - radius, 1e-15);
///
///     let z = radius * SQRT_3 / SQRT_2;
///     let d = point_cylinder_distance(a, b, radius, &[0.0, 0.0, z])?;
///     assert_approx_eq!(d, 0.0, 1e-14);
///     Ok(())
/// }
/// ```
Computes the signed distance from point to the surface of a cylinder parallel to x
Computes the signed distance from point to the surface of a cylinder parallel to x
pub fn point_cylinder_distance(a: &[f64], b: &[f64], radius: f64, p: &[f64]) -> Result<f64, StrError> {
    let ndim = a.len();
    if ndim != 3 {
        return Err("axis_a.len() == ndim must be 3");
    }
    if b.len() != ndim {
        return Err("axis_b.len() must equal center.len() == ndim");
    }
    if p.len() != ndim {
        return Err("p.len() must equal center.len() == ndim");
    }
    let center_distance = point_line_distance(a, b, p)?;
    let distance = center_distance - radius;
    Ok(distance)
}
pub fn point_cylinder_distance ( a : & [ f64 ] , b : & [ f64 ] , radius : f64 , p : & [ f64 ] ) -> Result < f64 , StrError > { let ndim = a . len ( ) ; if ndim != 3 { return Err ( " " ) ; } if b . len ( ) != ndim { return Err ( " " ) ; } if p . len ( ) != ndim { return Err ( " " ) ; } let center_distance = point_line_distance ( a , b , p ) ? ; let distance = center_distance - radius ; Ok ( distance ) }
Computes the signed distance from point to the surface of a cylinder parallel to x
Computes the signed distance from point to the surface of a cylinder parallel to x
a
&[f64]
b
&[f64]
radius
f64
p
&[f64]
a
&[f64]
b
&[f64]
radius
f64
p
&[f64]
input
`a` -- First 3D point on the cylinder axis
`b` -- Second 3D point on the cylinder axis (must be different than `a`)
`radius` -- cylinder radius
`p` -- 3D point
` a ` -- First 3D point on the cylinder axis ` b ` -- Second 3D point on the cylinder axis ( must be different than ` a ` ) ` radius ` -- cylinder radius ` p ` -- 3D point
output
Returns the signed distance (negative is inside)
Returns the signed distance ( negative is inside )
note
This works in 3D only.
This works in 3D only .
examples
None