Skip to content

Commit

Permalink
Changed Location compare to use quaternions
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Apr 19, 2023
1 parent f8ad67c commit ef35afa
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/build123d/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit ef35afa

Please sign in to comment.