2
$\begingroup$

The Cube should rolle like a cube should roll^^. In some cases the rotation goes wrong in case of a gimbal lock? How to avoid that? GIF

PNG

$\endgroup$
  • $\begingroup$ I don't know Animation nodes, but can it do axis-angle or quaternions. Those don't gimbal lock. $\endgroup$ – user27640 Jan 14 '17 at 0:15
  • $\begingroup$ Yes, it has axis-angle and quaternions. But I don't know how to set this up. It's pretty new to me. $\endgroup$ – Daniel Glebinski Jan 14 '17 at 0:56
2
$\begingroup$

This rotation behavior occurs because the first rotation causes a rotation in the axes as well. This would require you to recalculate the axis to use for the second rotation. Unfortunately this problem isn't the result of gimbal lock and won't go away if you're switching to quaternions.

A quick and dirty solution would be to change the order of your rotations depending on whether the cube is rolling in the x or y direction. I don't know if it's possible to change the rotation order for one node, but if you multiply the rotation matrices you end up with the same result. If you're sticking to nodes, use two Matrix Math and a Matrix Mix node. I just decided to switch to a script to reduce the amount of wiring.

Rolling Cube

This approach would require you to keep track of the cube's direction and manually add keyframes for the script input which changes the matrix multiplication order.

The fact that the orientation of the cube might change whenever you switch could lead to problems if you replace the cube with an object with less symmetry. But then it might be better to search for another approach as the x and y position of an empty alone isn't sufficient to determine the desired orientation of the final object.

order of rotation is important

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thank You for helping me. I can't test the script because of an TypeError in [Line:3 - can't multiply sequence by non-int of type 'float' (TypeError)] $\endgroup$ – Daniel Glebinski Jan 14 '17 at 14:07
  • $\begingroup$ @DanielGlebinski The input types for the script should be Float for both x and y and Boolean for the third value. I assume you picked Float List and tried to pipe Location directly into the script. $\endgroup$ – binweg Jan 14 '17 at 14:20
  • $\begingroup$ Sorry, was my fault. I used the Script Node incorrectly. $\endgroup$ – Daniel Glebinski Jan 14 '17 at 14:36
  • $\begingroup$ Still dirty but beautiful^^ Maybe I could automate the boolean with a case function. In one case the whole geometry flips and if the cube were detailed or textured asymmetrical it would flip and the flip would be recognizable. Works fine, thank you @binweg. $\endgroup$ – Daniel Glebinski Jan 14 '17 at 15:05

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.