parry2d/transformation/to_polyline/
cuboid_to_polyline.rs

1use crate::math::Real;
2use crate::shape::Cuboid;
3use crate::transformation::utils;
4use alloc::{vec, vec::Vec};
5use na::{self, Point2};
6
7impl Cuboid {
8    /// Discretize the boundary of this cuboid as a polygonal line.
9    pub fn to_polyline(&self) -> Vec<Point2<Real>> {
10        utils::scaled(unit_rectangle(), self.half_extents * 2.0)
11    }
12}
13
14/// The contour of a unit cuboid lying on the x-y plane.
15fn unit_rectangle() -> Vec<Point2<Real>> {
16    vec![
17        Point2::new(-0.5, -0.5),
18        Point2::new(0.5, -0.5),
19        Point2::new(0.5, 0.5),
20        Point2::new(-0.5, 0.5),
21    ]
22}