1

I'm new to ARKit, and I need to know what's exactly a rotation order for the camera in ARKit?

I googled a lot for this info but there is no clear answer.

Please I need answer with print example of camera transform matrix.

(Rx, Ry, Rz) 

or

(Rz, Ry, Rx) ?
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
lady
  • 356
  • 1
  • 2
  • 14

1 Answers1

3

In ARKit, SceneKit and RealityKit the default node's (entity's) orientation is expressed as

  • pitch, or rotation about X
  • yaw, or rotation about Y
  • roll, or rotation about Z

enter image description here

Apple Developer Documentation says:

SceneKit applies these rotations relative to the node’s pivot property in the reverse order of the components: first roll Z, then yaw Y, then pitch X. The rotation, eulerAngles, and orientation properties all affect the rotational aspect of the node’s transform property. Any change to one of these properties is reflected in the others.

Answer

Rotation order for ARKit objects is:

(Rz, Ry, Rx)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • Sorry for bad english, so in transform matrix should be the multiplying in reverse, rx.ry.rz right??? then why apple in its tutorial calculates yaw from column 0 x and column 1 x by atan2, I reviewed Euler Angles document, that's not right... could you help me ? I apprciate you .. – lady Sep 16 '20 at 18:18
  • zYour English is OK. At first read this post – https://stackoverflow.com/questions/45437037/arkit-what-do-the-different-columns-in-transform-matrix-represent/55695304#55695304 and this illustrated Medium story – https://medium.com/macoclock/augmented-reality-911-transform-matrix-4x4-af91a9718246 – Andy Jazz Sep 16 '20 at 19:03
  • 1
    For me, explanation in the links is very clear because I got it in OpenGl course, why I wonder then? my question is when we apply composed transformations, for example rz.ry.rx or any other order we could calculate yaw angle from atan2(sin y, cos y) why they consider this values in column 0 x and column 1 x? I wish I could explain my point .. Thank you @Andy Fedoroff – lady Sep 16 '20 at 19:22
  • 1
    Please give me Apple's link showing `atan2(sin(y0, cos(y))` calculation. – Andy Jazz Sep 16 '20 at 19:47
  • For atan2 formula it's sure not from apple, you can check euler angle pdf https://www.geometrictools.com/Documentation/EulerAngles.pdf and https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-trig it's very clear, but apple in tutorial https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip check this line in FocusSquere file : let yaw = atan2f(camera.transform.columns.0.x, camera.transform.columns.1.x) – lady Sep 16 '20 at 20:10
  • So, what you need it for? I mean, using this info for Apple matrices... – Andy Jazz Sep 16 '20 at 20:14
  • 1
    I need two things: first I need from anyone to show me after calculating rotation matrix in order of ARKit what these columns contain cos or sin for all angles x, y, z to understand every thing including why they consider yaw = atan2f(camera.transform.columns.0.x, camera.transform.columns.1.x) Second; although we could get yaw from camera.eulerAngle.y why they recalculate it? They calculated it based on x angle, is the x angle causes Gamble lock? if yes the order of camera rotation must rz.rx.ry or ry.rx.rz where rx in the middle based on this: https://www.youtube.com/watch?v=zc8b2Jo7mno – lady Sep 16 '20 at 20:39
  • 1
    Ok, I've got it. I'll try to answer it tomorrow. – Andy Jazz Sep 16 '20 at 21:29
  • 1
    Sorry @lady, I haven't found any info on rotation order in Apple matrices. Alas! – Andy Jazz Sep 17 '20 at 09:49
  • 1
    Thank you very much @Andy Fedoroff , Anyone else? – lady Sep 17 '20 at 18:07