1

Right now I am trying to understand the values within an ARKit transform matrix so I can quantify the movements of my SCNNode. From a previous post on stack overflow I have learned that the matrix contains information regarding the node's current translation, scale, rotation, and position.

What I am not understanding is which values are specifically associated with those four things. For example I have figured out that the first element of the 3rd column represents an X (horizontal) movement on the screen and the 2nd value of the 3rd column represents a Y (vertical) movement. But other than that I'm not sure what the rest of the values in the matrix mean.

Thanks for the help!

NFarrell
  • 255
  • 1
  • 17

2 Answers2

1

In a transformation matrix, the translation information is in the last column. Given a transformation matrix, you can extract the translation from the last column as below:

let translation = SCNVector3(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z)

Rotation and scaling use the first three columns and are more complex. Scale is the length of the first three column vectors, and to extract the rotation you need to divide the first three column vectors by the scaling factors just mentioned. You can refer to this link for a better understanding of scale and rotation and how to extract them.

M Reza
  • 18,350
  • 14
  • 66
  • 71
  • Thanks for the info. I now realize this after looking at some of my old graphics notes. For ARKit however, the transform matrix is in row-major order. So if you were to transpose all of the information you told me in your post, then it'd be applicable to ARKit transform matrices. – NFarrell Jan 17 '19 at 16:58
  • @NFarrell good point. this link was useful for me https://stackoverflow.com/questions/53435756/xcode-simd-issue-with-translation-and-rotation-matrix-example – M Reza Jan 17 '19 at 17:59
  • 1
    Yea that helps for sure. I was trying to quantify the rotations of my SCNNode as it moved around through using the transform matrix but it turns out that SCNNode's have a eulerAngle property that give the angles of rotation from each axis so i didn't have to do any math. Much easier and saved a lot of headaches – NFarrell Jan 18 '19 at 16:55
0

MohammadRF's answered cleared things up for me the best. However, ARKit's matrices are in row-major order so if you were to transpose the matrices from the information he gave then it would apply to ARKit.

NFarrell
  • 255
  • 1
  • 17