What are the first two columns in SCNMatrix4

醉酒当歌 提交于 2019-12-04 19:49:45

SCNMatrix4 is the 3d transformation matrix. In short:

M = T * R * S

Translation by (tx, ty, tz):

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

Scale by (sx, sy, sz):

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

Rotation by (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 |
    └                            ┘

By the way, it's simple to decompose the SCNMatrix4 using SceneKit framework:

let n = SCNNode()
n.transform = YOUR_MATRIX
let position = n.position
let orientation = n.orientation
let scale = n.scale
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!