Skip to content

Commit

Permalink
Support AABB calculation for arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jun 19, 2023
1 parent af98e6a commit a69a65f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/fj-core/src/algorithms/bounding_volume/edge.rs
Original file line number Diff line number Diff line change
@@ -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<Aabb<2>> {
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| {
Expand Down

0 comments on commit a69a65f

Please sign in to comment.