From ef35afa085f64a7292f7f83f5b6affc180efb76e Mon Sep 17 00:00:00 2001 From: Roger Maitland Date: Wed, 19 Apr 2023 14:15:42 -0400 Subject: [PATCH] Changed Location compare to use quaternions --- src/build123d/geometry.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/build123d/geometry.py b/src/build123d/geometry.py index 8d6666b2..ee0bfb45 100644 --- a/src/build123d/geometry.py +++ b/src/build123d/geometry.py @@ -1064,11 +1064,24 @@ def __pow__(self, exponent: int) -> Location: return Location(self.wrapped.Powered(exponent)) def __eq__(self, other: Location): - return ( - isinstance(other, Location) - and self.position == other.position - and self.orientation == other.orientation + """Compare Locations""" + if not isinstance(other, Location): + raise ValueError("other must be a Location") + quaternion1 = gp_Quaternion() + quaternion1.SetEulerAngles( + gp_EulerSequence.gp_Intrinsic_XYZ, + radians(self.orientation.X), + radians(self.orientation.Y), + radians(self.orientation.Z), + ) + quaternion2 = gp_Quaternion() + quaternion2.SetEulerAngles( + gp_EulerSequence.gp_Intrinsic_XYZ, + radians(other.orientation.X), + radians(other.orientation.Y), + radians(other.orientation.Z), ) + return self.position == other.position and quaternion1.IsEqual(quaternion2) def to_axis(self) -> Axis: """Convert the location into an Axis"""