1
$\begingroup$

I have simplified the scenario on bellow picture: enter image description here

I have line Bezier Curve which I'm using as a path for camera to move along. When camera is on top, it is pointing down, and when it is coming down, I have turned it 90 degrees to see sight from the box.

But when camera is on that position you see I'm unable to rotate it using X-axis.

  1. On the following picture I have used X-axis to rotate the camera landscape, but as you can see from the picture, it turns over the Z-axis:

enter image description here

  1. When I'm using Z-axis to rotate, it does that as expected:

enter image description here

When the camera is on top, it rotates correctly. What I do not know on this?

$\endgroup$
2
  • 1
    $\begingroup$ I had just posted an explanation of local space when I realized that it was gimbal lock. Quaternion rotation or a different rotation order should fix the problem. $\endgroup$ – HISEROD Jan 3 at 3:32
  • $\begingroup$ Hi @HISEROD, thank you for pointing to gimbal lock. Tiny surprise to found such a problem on path following. I have tried to learn it, but so far no success. Will update if I found the good way of solving this. $\endgroup$ – Pepi Jan 3 at 23:47
1
$\begingroup$

This strange behavior is called gimbal lock. It is caused by the interdependency of the three rotation axes.

When the middle axis (Y in the case of XYZ rotation) is set to any value which results in a ±90° rotation, the first axis is aligned with the last. At this point, a change to the first or last axial rotation can only rotate around the last axis (Z in the case of XYZ).

A good example can be seen in this gif by Peyman Massoudi:

Notice how the red X ring is rotated to the blue Z ring.

The solution is to use axis-angle, quaternion or a different rotation order (e.g. XZY, ZXY, YZX,...) to rotate the object.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.