NFarrell
NFarrell

Reputation: 255

What do values in ARKit transform matrices represent?

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!

Upvotes: 1

Views: 713

Answers (2)

NFarrell
NFarrell

Reputation: 255

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.

Upvotes: 0

M Reza
M Reza

Reputation: 19698

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.

Upvotes: 1

Related Questions