From a69a65f8c75acb402efcb8b1517d3f6800ad2fcf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Jun 2023 10:21:53 +0200 Subject: [PATCH] Support AABB calculation for arcs --- .../src/algorithms/bounding_volume/edge.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/algorithms/bounding_volume/edge.rs b/crates/fj-core/src/algorithms/bounding_volume/edge.rs index ba6d56a09e..d8f914d537 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/edge.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/edge.rs @@ -1,15 +1,21 @@ -use fj_math::Aabb; +use fj_math::{Aabb, Vector}; use crate::{geometry::curve::Curve, objects::HalfEdge}; impl super::BoundingVolume<2> for HalfEdge { fn aabb(&self) -> Option> { match self.curve() { - Curve::Circle(_) => { - // I don't currently have an example model to test this with. - // This should change soon, and then this will panic and can be - // addressed. - todo!("Computing AABB of arc is not supported yet") + Curve::Circle(circle) => { + // Just calculate the AABB of the whole circle. This is not the + // most precise, but it should do for now. + + let center_to_min_max = + Vector::from([circle.radius(), circle.radius()]); + + Some(Aabb { + min: circle.center() - center_to_min_max, + max: circle.center() + center_to_min_max, + }) } Curve::Line(_) => { let points = self.boundary().map(|point_curve| {