Skip to content

Commit

Permalink
Implement AbsDiffEq for Circle
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Aug 3, 2022
1 parent 78d5a48 commit 2923d23
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/fj-math/src/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ impl<const D: usize> Circle<D> {
}
}

impl<const D: usize> approx::AbsDiffEq for Circle<D> {
type Epsilon = <Scalar as approx::AbsDiffEq>::Epsilon;

fn default_epsilon() -> Self::Epsilon {
Scalar::default_epsilon()
}

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.center.abs_diff_eq(&other.center, epsilon)
&& self.a.abs_diff_eq(&other.a, epsilon)
&& self.b.abs_diff_eq(&other.b, epsilon)
}
}

#[cfg(test)]
mod tests {
use std::f64::consts::{FRAC_PI_2, PI};
Expand Down

0 comments on commit 2923d23

Please sign in to comment.