SCNMatrix4 的前两列是什么

What are the first two columns in SCNMatrix4

我正在阅读这个结构的文档,但似乎没有足够的信息,m3 是矩阵的第 3 列,m4 是第 4 列,包含有关节点在 3D 中的方向和位置的信息space 相应地,我知道是因为 Udemy 上的一些课程。

现在提取方向和其他东西的唯一方法是:

guard let pointOfView = sceneView.pointOfView else { return }
let transform = pointOfView.transform
let orientaiton = SCNVector3(-transform.m31, -transform.m32, -transform.m33)

我想 API 与 SceneKit 相比,ARKit 是不同的

A​​pple 文档 link:https://developer.apple.com/documentation/scenekit/scnmatrix4/1621081-m11

SCNMatrix4 是 3d transformation matrix。简而言之:

M = T * R * S

(tx, ty, tz) 翻译:

    ┌             ┐
T = | 1  0  0  tx |
    | 0  1  0  ty |
    | 0  0  1  tz |
    | 0  0  0   1 |
    └             ┘

按 (sx, sy, sz) 缩放:

    ┌               ┐
S = | sx   0   0  0 |
    |  0  sy   0  0 |
    |  0   0  sz  0 |
    |  0   0   0  1 |
    └               ┘

旋转 (rx, ry, rz):

R = ZYX
    ┌                           ┐
X = |  1   0        0         0 |
    |  0   cos(rx)  -sin(rx)  0 |
    |  0   sin(rx)  cos(rx)   0 |
    |  0   0        0         1 |
    └                           ┘
    ┌                             ┐
Y = |  cos(ry)    0   sin(ry)   0 |
    |  0          1   0         0 |
    |  -sin(ry)   0   cos(ry)   0 |
    |  0          0   0         1 |
    └                             ┘
    ┌                            ┐
Z = |  cos(rz)   -sin(rz)  0   0 |
    |  sin(rz)   cos(rz)   0   0 |
    |  0         0         1   0 |
    |  0         0         0   1 |
    └                            ┘

对了,使用SceneKit框架分解SCNMatrix4很简单:

let n = SCNNode()
n.transform = YOUR_MATRIX
let position = n.position
let orientation = n.orientation
let scale = n.scale