SCNMatrix4的前两列是什么? [英] What are the first two columns in SCNMatrix4

查看:437
本文介绍了SCNMatrix4的前两列是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was reading the documentation for this struct but there seem not be enough information, m3 being the 3rd column of the matrix and m4 the 4th column contain the information about orientation and location of the node in 3D space correspondingly that I know because of some course on Udemy.

现在,提取方向和其他方面的唯一方法是:

Also right now the only way to extract the orientation and other things is:

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

我认为与SceneKit相比,ARKit的API不同

I guess API is different for the ARKit as compared to SceneKit

Apple文档链接: https:/ /developer.apple.com/documentation/scenekit/scnmatrix4/1621081-m11

Apple documentation link: https://developer.apple.com/documentation/scenekit/scnmatrix4/1621081-m11

推荐答案

SCNMatrix4是3d 转换矩阵。简而言之:

SCNMatrix4 is the 3d transformation matrix. In short:

M = T * R * S

翻译(tx,ty,tz):

Translation by (tx, ty, tz):

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

按(sx,sy,sz)换算:

Scale by (sx, sy, sz):

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

轮换(rx,ry,rz):

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 |
    └                            ┘

顺便说一句,使用SceneKit框架分解SCNMatrix4很简单:

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

这篇关于SCNMatrix4的前两列是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆