On the first screen you can drag the input vector v1 the input vector. This is the vector we are calling .reflect()
on.
You can also drag the normal vector. This is the
argument we pass to v1.reflect(normal)
. It represent the normal vector of the
surface that v1 will be reflected on. This surface is rendered as the black line on the second screen.
And you can observe how the reflected vector evolves.
The second screen is another representation to help visualize how .reflect
works. It shows:
Note how when v1 and normal are perpendicular, ie. when the vector is parallel to the surface to reflect on, reflected keeps the same direction. In a physical simulation that's an edge case to handle before (or after)
calling .reflect()
.
Note the magnitude of the normal vector doesn't impact the result of .reflect()
(Because the method normalize it
before doing its computation)
Input
v1
normal
v1.reflect(normal)