Search code examples
swiftcocoa-touchmatrixaugmented-realityarkit

Get Camera Translation from ARCamera


I am experimenting with Apple's ARKit and have a question regarding camera transformations. Which of the values in the transform matrix represent how far the user has travelled from the point of origin? Calling

self.sceneView.session.currentFrame!.camera.transform.columns.0.x 

does not seem to yield the correct X translation.

Additionally, what would be the correct location for Y and Z?


Solution

  • The last column of a 4x4 transform matrix -- matrix.columns.3 in this case -- is the translation vector. See this old answer for some background on 4x4 transform matrices and how they work.