I'm trying to create a script that shoots a beam into a mirror using raycasting. The beam is then deflected by the mirror, based on the direction the beam is coming from, where it hit the mirror, and the rotation of the mirror. However, I don't know how to piece that all together to calculate the direction the beam will be deflected in. If anyone has any ideas, algorithms, or helpful links, please let me know. Thanks.
The mirror will always be rectangular, so the algorithm doesn't have to work universally for every shape.
The normal of a plane is the direction pointing away from the surface (e.g., the normal along the top of a table is "up").
A direction d
can be reflected through a plane defined by unit normal n
with the following formula:
reflection = d - 2 * d:dot(n) * n
You can get the normal of the surface that a ray collides with using FindPartOnRay
.