简体   繁体   English

ARKit 变换矩阵中的值代表什么?

[英]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.现在我正在尝试了解 ARKit 变换矩阵中的值,以便量化 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.例如,我发现第三列的第一个元素表示屏幕上的 X(水平)移动,第三列的第二个值表示 Y(垂直)移动。 But other than that I'm not sure what the rest of the values in the matrix mean.但除此之外,我不确定矩阵中的其余值是什么意思。

Thanks for the help!谢谢您的帮助!

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.您可以参考此链接以更好地了解缩放和旋转以及如何提取它们。

MohammadRF's answered cleared things up for me the best. MohammadRF 的回答为我最好地解决了问题。 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.但是,ARKit 的矩阵按行优先顺序排列,因此如果您要从他提供的信息中转置矩阵,那么它将适用于 ARKit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM