My background:
I have taken an introductory class or two in linear algebra at university, but it was a few years ago and I have not practiced it since. My terminology might be off, but I believe my text should be clear enoungh for everyone to understand.
Problem:
I am trying to build a 3-dimensional controller for a game and have run into an issue that I cannot solve. I need to find a 3-dimensional direction vector to use for moving an object along a plane, parallel to the plane. The directional vector should be based on a 2-dimensional input vector along the x- and z-axis, in combination with the rotation (any / all of the three axes) of the plane.
I think the easiest way for me to explain the problem that needs to be solved is to try to illustrate it using two examples.
Assumptions:
Left-handed coordinate system. We have a sphere with a radius of 0.5 with its center located at (0, 0.5, 0). I guess we can consider the center of the sphere the only thing of importance, but maybe a sphere can help build a visual image. The input vector used to translate the sphere with in both examples below is (1, 0, 1)
Examples:
- There is a xz-plane located at y = 0, so the sphere is in contact with the surface of the plane. After moving the sphere along the input vector, the sphere will be located at (0, 0.5, 0) + (1, 0, 1) = (1, 0.5, 1)
- The plane from example 1 has been rotated 89 degress around the z-axis and moved ~0.5 on the x-axis (not using 90 degrees rotation and exact movement since it would make it a bit harder to illustrate why the sphere should be moved the way I want it to move). The sphere is still in contact with the surface of the plane, but from the side. If the sphere were to be moved using the input vector it would move through the plane, but I want the sphere to move parallel to the plane. I want to … rotate? the input vector somehow. The final position of the sphere should be roughly (0.05, 0.95, 1). The location of the sphere after the movement should be the same as if we were to rotate the final location of the sphere from example 1 around the world z-axis the same number of degrees as the plane is rotated around the z-axis in this example.
Available data:
The data available is the location of the sphere, the input direction vector and the normal of the plane. Is this information enough to be able to solve the problem, and if so, how? If not, what other data is required?