parry2d/transformation/to_polyline/
ball_to_polyline.rs

1use crate::math::{Real, RealField, Vector2};
2use crate::shape::Ball;
3use crate::transformation::utils;
4use alloc::vec::Vec;
5
6impl Ball {
7    /// Discretize the boundary of this ball as a polygonal line.
8    pub fn to_polyline(&self, nsubdivs: u32) -> Vec<Vector2> {
9        let diameter = self.radius * 2.0;
10        let two_pi = Real::two_pi();
11        let dtheta = two_pi / (nsubdivs as Real);
12
13        let mut pts = Vec::with_capacity(nsubdivs as usize);
14        utils::push_xy_arc(diameter / 2.0, nsubdivs, dtheta, &mut pts);
15
16        pts
17    }
18}