-
Notifications
You must be signed in to change notification settings - Fork 54
✨ FEAT: Add reflection transformation with verification tests #2414
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: develop
Are you sure you want to change the base?
✨ FEAT: Add reflection transformation with verification tests #2414
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is looking good!
Just one thing I'm wondering: have you checked the codebase for places where transformations are used and where the reflection might also need to be incorportaed?
f8f4fce
to
ca052da
Compare
@momchil-flex Thank you! The geometrical transformations are mainly checked in
Regarding other uses of geometrical transformations:
Let me know what you think. |
I implemented the specialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, indeed, from the things you identified, materializing the transformation immediately for the PolySlab for efficiency seems the only thing that needed to be done, thanks for getting it in already!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @damianofranzo this basically looks good for me to integrate into our codebase, awesome job.
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
## [Unreleased] | |||
|
|||
### Added | |||
- For efficiency, `reflected` `PolySlab`-s now return updated `PolySlab` objects rather than a `Transformed` object, except when the normal of the plane of reflection has a non-zero component along the slab axis, in which case `Transformed` is still returned. | |||
- The method `Geometry.reflected` can be used to create a reflected copy of any geometry off a plane. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nitpicky but I would just merge these two items into one because no "change" was made to the reflected
operation as it didn't exist before. Maybe something like
"The method Geometry.reflected
can be used to create a reflected copy of any geometry off a plane. As for other transformations, for efficiency, reflected
PolySlab
-s directly return an updated PolySlab
objects rather than a Transformed
object, except when the normal of the plane of reflection has a non-zero component along the slab axis, in which case Transformed
is still returned."
This PR addresses feature request #2157 by adding the capability to apply reflection transformations to geometry objects.
Key changes include:
AbstractReflection
andReflectionFromPlane
classes, calculating the reflection matrix from a normal vector with input validation.Transformed.reflection(normal)
to provide the 4x4 reflection matrix..reflected(normal)
to the classGeometry
to return the reflected copy of the geometry.test_general_reflection
to verify the reflection transformation is invariant to the scale and sign of the normal vector.Includes necessary imports and type definitions.
Considerations
AbstractReflection
is basically a copy ofAbstractRotation
, with the difference that a reflection can never be an identity, and as a consequence,isidentity
is omitted.ReflectionFromPlane
only accepts a normal in the format(x, y, z)
. Initially, I thought the input could also have been0
,1
, or2
to specify YZ, XZ, and XY planes, respectively, but then I realized that this could have caused some confusion when used as API.AbstractReflection
andAbstractRotation
into a more general abstraction, adding a possible center of reflection/rotation, or operations of this type).