pub fn point_circle_distance(center: &[f64], radius: f64, p: &[f64]) -> Result<f64, StrError> {
    let ndim = center.len();
    if ndim != 2 {
        return Err("center.len() == ndim must be 2");
    }
    if p.len() != ndim {
        return Err("x.len() must equal center.len() == ndim");
    }
    let center_distance = point_point_distance(center, p)?;
    let distance = center_distance - radius;
    Ok(distance)
}
/// Computes the signed distance from point to circle perimeter
///
/// # Input
///
/// `center` -- 2D circle center
/// `radius` -- circle radius
/// `p` -- 2D point
///
/// # Output
///
/// Returns the signed distance (negative is inside).
///
/// # Note
///
/// This works in 2D only.
///
/// # Examples
///
/// ```
/// use gemlab::geometry::point_circle_distance;
/// use gemlab::StrError;
/// use gemlab::util::SQRT_2;
/// use russell_chk::assert_approx_eq;
///
/// fn main() -> Result<(), StrError> {
///     let center = &[3.0, 4.0];
///     let radius = 5.0;
///     let d = point_circle_distance(center, radius, &[3.0, 4.0])?;
///     assert_eq!(d, -radius);
///
///     let d = point_circle_distance(center, radius, &[8.0, 4.0])?;
///     assert_eq!(d, 0.0);
///
///     let d = point_circle_distance(center, radius, &[3.0, 9.0])?;
///     assert_eq!(d, 0.0);
///
///     let d = point_circle_distance(center, radius, &[8.0, 9.0])?;
///     assert_approx_eq!(d, radius * SQRT_2 - radius, 1e-15);
///     Ok(())
/// }
/// ```
Computes the signed distance from point to circle perimeter
Computes the signed distance from point to circle perimeter
pub fn point_circle_distance(center: &[f64], radius: f64, p: &[f64]) -> Result<f64, StrError> {
    let ndim = center.len();
    if ndim != 2 {
        return Err("center.len() == ndim must be 2");
    }
    if p.len() != ndim {
        return Err("x.len() must equal center.len() == ndim");
    }
    let center_distance = point_point_distance(center, p)?;
    let distance = center_distance - radius;
    Ok(distance)
}
pub fn point_circle_distance ( center : & [ f64 ] , radius : f64 , p : & [ f64 ] ) -> Result < f64 , StrError > { let ndim = center . len ( ) ; if ndim != 2 { return Err ( " " ) ; } if p . len ( ) != ndim { return Err ( " " ) ; } let center_distance = point_point_distance ( center , p ) ? ; let distance = center_distance - radius ; Ok ( distance ) }
Computes the signed distance from point to circle perimeter
Computes the signed distance from point to circle perimeter
center
&[f64]
radius
f64
p
&[f64]
center
&[f64]
radius
f64
p
&[f64]
input
`center` -- 2D circle center
`radius` -- circle radius
`p` -- 2D point
` center ` -- 2D circle center ` radius ` -- circle radius ` p ` -- 2D point
output
Returns the signed distance (negative is inside).
Returns the signed distance ( negative is inside ) .
note
This works in 2D only.
This works in 2D only .
examples
None