Will this be the reason for the cardan lock?

I make a very simple three-dimensional scene, having 5 points in world coordinates. I would like to move around the scene, so I define a camera with both the UP and OUT vectors. With this information, I generate a rotation matrix in each frame, which I will apply to vectors to get the coordinates of the camera.

The question is what I read about gimbal lock as a problem using this method, but will this happen in this case?

Please note that I generate the rotation matrix in each frame, and I do not rotate accurately. So can a castle happen in this situation? If that were the case, what would you suggest to safely use rotation (from the vectors UP and OUT)?

thanks

+2
source share
2 answers

If by OUT you mean "forward", and it is always perpendicular to the vector UP, then NO, you will not encounter cardan lock.

What you are doing is creating an orientation matrix from the UP and FORWARD vectors and applying this frame, which is a fairly common method for moving a camera in space. You do not apply several turns using Euler angles, which may cause the driveshaft to lock.

Note. To create a matrix, you will also need to create a β€œleft” (or right) vector from the UP and FORWARD vectors. A good introduction to this is here - note that this example applies rotation to the camera matrix, which is a completely optional step.

Wikipedia has a good explanation of gimbal lock .

+4
source

When using the matrix approach to generate rotation matrices (for X, Y, Z), you will encounter the gimbal-lock problem, and then multiply them by obtaining the final rotation matrix. If I understand that you will do this, you use the OUT vector to get the angles (alpha, beta, gamma), then you calculate the matrices, finally - you multiply them to get the final rotation matrix - then yes, you will come across a cardan lock .

One way to get rid of this problem is to use Quaternions for calculations.

Also, here I found an OpenGL tutorial on how to implement them.

+1
source

All Articles