-
Notifications
You must be signed in to change notification settings - Fork 53
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
WIP: Vertex reflection along a plane #129
Conversation
I've fixed the reflection logic and landed your changes 👍 |
The reason the reflection math you found wasn't working is that it's for calculating a reflection as if the normal was bouncing off the plane (like light reflecting off a mirror) but you want the reflection along the plane (i.e. where the object appears in the mirror - which is behind the plane not in front of it). I'm also not great at math so there's probably a better way to do it, but I solved it by translating the position of the end of the normal (the same way you did for the vertex position) and then subtracting the reflected position from that to tun it back into a normal vector instead of a position vector. |
Superb. Thank you @nicklockwood 🙌 Also, thanks for explaining the reflection logic and how you overcame this. |
Description
Work in progress proposal to add supporting methods to reflect
Mesh
andPolygon
vertices along a givenPlane
.This is currently a partial implementation as the reflected vertex normal yields incorrect results.
Discussion
I have implemented the appropriate methods for reflecting the vertex positions but the calculations used to determine the reflected normal of the plane are currently incorrect. This is most likely due to my lack of comprehension of the concepts discussed here and how this should be implemented. This requires further discussion.
The ordering of the polygon vertices is reversed using
.inverted()
which I believe to be correct but this feels a little like a code smell. Reversing the ordering feels intuitive to me as the polygons are mirrored 🤷♂️Basic coverage for reflecting a quad has been added to the unit test suite but this will likely need additional tests for polygons which are coplanar / intersecting. I will bolster these further if there is any interest in merging this PR.