pub fn find_on_circle(&self, center: &[f64], radius: f64) -> Result<HashSet<usize>, StrError> {
        // check
        if self.ndim != 2 {
            return Err("this works in 2D only");
        }
        if center.len() != self.ndim {
            return Err("center.len() must equal ndim");
        }

        // find containers near the circle
        let nearest_containers = self.containers_near_circle(center, radius)?;

        // find container points near the circle
        let mut ids = HashSet::new();
        for index in nearest_containers {
            let container = self.containers.get(&index).unwrap();
            for item in container.values() {
                let distance = point_circle_distance(center, radius, &item.x)?;
                if f64::abs(distance) <= self.radius_tol {
                    ids.insert(item.id.clone());
                }
            }
        }
        Ok(ids)
    }
/// Finds points on the perimeter of a circle (2D only)
///
/// # Input
///
/// `center` -- 2D circle center
/// `radius` -- circle radius
///
/// # Output
///
/// Returns the ids of points.
///
/// # Note
///
/// This works in 2D only.
Finds points on the perimeter of a circle (2D only)
Finds points on the perimeter of a circle ( 2D only )
pub fn find_on_circle(&self, center: &[f64], radius: f64) -> Result<HashSet<usize>, StrError> {
        // check
        if self.ndim != 2 {
            return Err("this works in 2D only");
        }
        if center.len() != self.ndim {
            return Err("center.len() must equal ndim");
        }
        // find containers near the circle
        let nearest_containers = self.containers_near_circle(center, radius)?;
        // find container points near the circle
        let mut ids = HashSet::new();
        for index in nearest_containers {
            let container = self.containers.get(&index).unwrap();
            for item in container.values() {
                let distance = point_circle_distance(center, radius, &item.x)?;
                if f64::abs(distance) <= self.radius_tol {
                    ids.insert(item.id.clone());
                }
            }
        }
        Ok(ids)
    }
pub fn find_on_circle ( & self , center : & [ f64 ] , radius : f64 ) -> Result < HashSet < usize > , StrError > { // check if self . ndim != 2 { return Err ( " " ) ; } if center . len ( ) != self . ndim { return Err ( " " ) ; } // find containers near the circle let nearest_containers = self . containers_near_circle ( center , radius ) ? ; // find container points near the circle let mut ids = HashSet :: new ( ) ; for index in nearest_containers { let container = self . containers . get ( & index ) . unwrap ( ) ; for item in container . values ( ) { let distance = point_circle_distance ( center , radius , & item . x ) ? ; if f64 :: abs ( distance ) <= self . radius_tol { ids . insert ( item . id . clone ( ) ) ; } } } Ok ( ids ) }
Finds points on the perimeter of a circle (2D only)
Finds points on the perimeter of a circle ( 2D only )
&self
center
&[f64]
radius
f64
&self
center
&[f64]
radius
f64
input
`center` -- 2D circle center
`radius` -- circle radius
` center ` -- 2D circle center ` radius ` -- circle radius
output
Returns the ids of points.
Returns the ids of points .
note
This works in 2D only.
This works in 2D only .