Skip to content

Commit f595b94

Browse files
committed
Use angle_between in angle equality tests
1 parent 9fb62bf commit f595b94

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

crates/geometry/src/angle.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ impl<T: Euclid + RealField> RelativeEq for Angle<T> {
4242
epsilon: Self::Epsilon,
4343
max_relative: Self::Epsilon,
4444
) -> bool {
45-
self.normalized()
45+
self.angle_between(other.clone())
4646
.0
47-
.relative_eq(&other.normalized().0, epsilon, max_relative)
47+
.relative_eq(&T::zero(), epsilon, max_relative)
4848
}
4949
}
5050

5151
impl<T: Euclid + RealField> PartialEq for Angle<T> {
5252
fn eq(&self, other: &Self) -> bool {
53-
self.normalized().0 == other.normalized().0
53+
self.angle_between(other.clone()).0 == T::zero()
5454
}
5555
}
5656

@@ -62,10 +62,9 @@ impl<T: Euclid + RealField + Clone> AbsDiffEq for Angle<T> {
6262
}
6363

6464
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
65-
let difference = (self.clone() - other.clone()).normalized().into_inner();
66-
67-
difference.abs_diff_eq(&T::zero(), epsilon.clone())
68-
|| difference.abs_diff_eq(&T::two_pi(), epsilon)
65+
self.angle_between(other.clone())
66+
.0
67+
.abs_diff_eq(&T::zero(), epsilon)
6968
}
7069
}
7170

0 commit comments

Comments
 (0)