- #1
_Nate_
- 20
- 0
I'm working on a 3d physics simulator, and I'm trying to build a nice, easy-to-use camera into it. Currently, the camera allows you to specify inputs that modify (among other things such as zoom) its pitch, yaw, roll, strafe, movement, and elevation.
The way it currently works is this: The rotation of the camera is stored in a quaternion. Changes in pitch, yaw, and roll are stored in a Euler Vector in the form (change in Pitch, change in Yaw, change in Roll). Every update, this rotation vector is converted to a unit quaternion and multiplied into the camera's quaternion. This data is used to transform the camera.
Now, I also have a translation vector in the form (change in Strafe, change in Elevation, change in Movement). I need to know how to translate this into an actual translation vector, in other words (delta x, delta y, delta z).
How do I do this?
My current idea is that I need to find the up-vector, the left-vector, and the front-vector of the quaternion, scale the up-vector by the elevation, the left-vector by the strafe, and the front-vector by the movement. If this is the best way, then how do I extract the up, left, and front vectors from a rotation quaternion?
Thank you.
Edit: solved. Found an easy way to get around doing all the math. For anyone in a similar position later, the way to do this is to create a matrix from the quaternion (if your quaternion does not already have this functionality, it is easy to achieve). The first three rows (or columns, depending on your implementation) represent the left, up, and front vectors respectively.
The way it currently works is this: The rotation of the camera is stored in a quaternion. Changes in pitch, yaw, and roll are stored in a Euler Vector in the form (change in Pitch, change in Yaw, change in Roll). Every update, this rotation vector is converted to a unit quaternion and multiplied into the camera's quaternion. This data is used to transform the camera.
Now, I also have a translation vector in the form (change in Strafe, change in Elevation, change in Movement). I need to know how to translate this into an actual translation vector, in other words (delta x, delta y, delta z).
How do I do this?
My current idea is that I need to find the up-vector, the left-vector, and the front-vector of the quaternion, scale the up-vector by the elevation, the left-vector by the strafe, and the front-vector by the movement. If this is the best way, then how do I extract the up, left, and front vectors from a rotation quaternion?
Thank you.
Edit: solved. Found an easy way to get around doing all the math. For anyone in a similar position later, the way to do this is to create a matrix from the quaternion (if your quaternion does not already have this functionality, it is easy to achieve). The first three rows (or columns, depending on your implementation) represent the left, up, and front vectors respectively.
Last edited: