ios – Scene Kit Rotation – rotating around X and Y axis only, causing Z rotation


I am trying to control the orientation of a box in Scene Kit (iOS) using gestures. I am using the translation in x and y to update the x and y rotation of the SCNNode.

After a long search I have realised that x and y rotation will always lead to z rotation, thanks to this excellent post: gamedev stack exchange: I’m rotating an object on two axes, so why does it keep twisting around the third axis?

So I am trying to get the z rotation causes, and then remove this from my object by applying the inverse quaternion however when I rotate the object 90 deg around x, and then 90 deg around Y it behaves VERY weirdly.

It is almost behaving as it is in gimbal lock, but I did not think that using quaternion in the way that I am would cause gimbal lock in this way.

I am sure it is something I am missing, or perhaps I am not able to remove the z rotation in this way.

Thanks!

I have added a video of the strange behaviour here

And the code example is here

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img