Add `Plane.reverse()` method
Closed this issue · 2 comments
tobywf commented
It might be good to add a Plane.reverse()
method, analogue to Axis.reverse()
and Vector.reverse()
.
Pros:
Axis
implements both__neg__
andreverse()
,Vector
implements both__neg__
andreverse()
, whilePlane
currently only implements__neg__
.- I spent longer than I care to admit trying to figure out how to reverse/invert a plane.
Plane.reverse()
helps with discoverability due to auto-complete. - A method has a clear operator precedence.
-Plane.XY.offset(10.0)
applies the offset first, and then the reversal.(-Plane.XY).offset(10.0)
is required to first reverse and then offset.Plane.XZ.reverse().offset(10.0)
works as intended.
Cons:
Axis.reverse()
corresponds directly to the OCCT methodReversed
.Plane.reverse()
doesn't; butVector.reverse()
also doesn't.- There would be two ways to reverse a plane. But that's true of
Axis
andVector
also. - There's already
Plane.reverse_transform()
, which is close in name. - Could be that e.g.
invert()
is a more appropriate name.
Overall, I think Plane.reverse()
makes sense, but let me know. Looks like an easy PR; happy to submit one if you'd like.
tobywf commented
Example of operator precedence issue:
Plane.reverse = lambda s: -s
print(-Plane.XY.offset(10.0))
print((-Plane.XY).offset(10.0))
print(Plane.XY.reverse().offset(10.0))
Plane(o=(0.00, 0.00, 10.00), x=(1.00, 0.00, 0.00), z=(-0.00, -0.00, -1.00))
Plane(o=(0.00, 0.00, -10.00), x=(1.00, 0.00, 0.00), z=(-0.00, -0.00, -1.00))
Plane(o=(0.00, 0.00, -10.00), x=(1.00, 0.00, 0.00), z=(-0.00, -0.00, -1.00))
gumyr commented
Done.