Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plane.reverse() method #546

Closed
tobywf opened this issue Feb 9, 2024 · 2 comments
Closed

Add Plane.reverse() method #546

tobywf opened this issue Feb 9, 2024 · 2 comments

Comments

@tobywf
Copy link

tobywf commented Feb 9, 2024

It might be good to add a Plane.reverse() method, analogue to Axis.reverse() and Vector.reverse().

Pros:

  • Axis implements both __neg__ and reverse(), Vector implements both __neg__ and reverse(), while Plane 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 method Reversed. Plane.reverse() doesn't; but Vector.reverse() also doesn't.
  • There would be two ways to reverse a plane. But that's true of Axis and Vector 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
Copy link
Author

tobywf commented Feb 9, 2024

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 added a commit that referenced this issue Feb 10, 2024
@gumyr
Copy link
Owner

gumyr commented Feb 10, 2024

Done.

@gumyr gumyr closed this as completed Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants