Strafe and translation vectors in a 3d physics simulator

Click For Summary
SUMMARY

This discussion focuses on implementing camera movement in a 3D physics simulator using quaternion rotations and translation vectors. The user initially faced challenges in converting a translation vector, defined by changes in strafe, elevation, and movement, into a delta vector (delta x, delta y, delta z). The solution involved creating a transformation matrix from the quaternion, which directly provides the left, up, and front vectors necessary for translating the camera's position. This method simplifies the process by avoiding complex mathematical calculations.

PREREQUISITES
  • Understanding of quaternion mathematics and their application in 3D graphics.
  • Familiarity with Euler angles and their conversion to quaternions.
  • Knowledge of transformation matrices and their role in 3D space.
  • Basic programming skills in a language suitable for 3D simulation, such as C++ or Python.
NEXT STEPS
  • Learn how to create and manipulate transformation matrices from quaternions in 3D graphics.
  • Study the relationship between Euler angles and quaternions in depth.
  • Explore camera control techniques in 3D environments, focusing on user input handling.
  • Investigate performance optimization strategies for real-time physics simulations.
USEFUL FOR

Game developers, 3D graphics programmers, and anyone involved in creating physics-based simulations who seeks to enhance camera control and movement mechanics.

_Nate_
Messages
19
Reaction score
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.
 
Last edited:
Physics news on Phys.org
Thanks for telling us.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 50 ·
2
Replies
50
Views
5K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
21
Views
4K