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