ARKit – Transform Matrix 中的不同列代表什么? [英] ARKit – What do the different columns in Transform Matrix represent?

查看:36
本文介绍了ARKit – Transform Matrix 中的不同列代表什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ARAnchor 的 4x4 矩阵有 4 列.矩阵的第四列包含 xyz 坐标的 3 个平移值.

我想知道其他 3 列代表什么?

解决方案

ARKit、RealityKit 和 SceneKit 框架使用 4 x 4 转换矩阵 来平移、旋转、缩放和剪切 3D 对象(就像 simd_float4x4矩阵类型).让我们看看这些矩阵是什么样的.

在 3D 图形中,我们经常使用带有 16 个有用元素的 4x4 矩阵.Identity 4x4 矩阵如下:

在这 16 个元素之间有 6 个不同的剪切系数:

剪切XY剪切 XZ剪切YX剪切YZ剪切 ZX剪切ZY

在剪切矩阵中,它们如下:

因为在这个矩阵中根本没有旋转系数,所以有六个剪切系数和三个比例系数> 允许您使用魔术三角(sin>cos).

以下是如何使用剪切和缩放元素绕 Z 轴旋转 3D 对象 (CCW) 的示例:

使用剪切和缩放元素查看 3 种不同的旋转模式:

当然还有4中的3个翻译元素(tx,ty,tz)x4 Matrix 位于最后一列:

 ┌ ┐|1 0 0 交易 ||0 1 0 ty ||0 0 1 兹 ||0 0 0 1 |└ ┘

<块引用>

ARKit、SceneKit 和 RealityKit 中列的索引为:0123.

第四列(索引 3)用于翻译值:

var translation = matrix_identity_float4x4翻译.columns.3.x翻译.columns.3.y翻译.columns.3.z


您可以阅读我关于MATRICES.


透视和正投影

位于4x4 矩阵 底行的值用于透视投影.

当然,您还需要查看如何设置 正射投影.

An ARAnchor's 4x4 matrix has 4 columns. The fourth column of the matrix contains 3 translate values for x, y, and z coordinates.

I was wondering what the other 3 columns represent?

解决方案

ARKit, RealityKit and SceneKit frameworks use 4 x 4 Transformation Matrices to translate, rotate, scale and shear 3D objects (just like simd_float4x4 matrix type). Let's see how these matrices look like.

In 3D Graphics we often use a 4x4 Matrix with 16 useful elements. The Identity 4x4 Matrix is as following:

Between those sixteen elements there are 6 different shearing coefficients:

shear XY
shear XZ
shear YX
shear YZ
shear ZX
shear ZY

In Shear Matrix they are as followings:

Because there are no Rotation coefficients at all in this Matrix, six Shear coefficients along with three Scale coefficients allow you rotate 3D objects about X, Y, and Z axis using magical trigonometry (sin and cos).

Here's an example how to rotate 3D object (CCW) about its Z axis using Shear and Scale elements:

Look at 3 different Rotation patterns using Shear and Scale elements:

And, of course, 3 elements for translation (tx,ty,tz) in the 4x4 Matrix are located on the last column:

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

The columns' indices in ARKit, SceneKit and RealityKit are: 0, 1, 2, 3.

The fourth column (index 3) is for translation values:

var translation = matrix_identity_float4x4

translation.columns.3.x
translation.columns.3.y
translation.columns.3.z


You can read my illustrated story about MATRICES on Medium.


Perspective and orthographic projections

Values located in the bottom row of a 4x4 matrix is used for perspective projection.

And, of course, you need to see an example of how to setup an orthographic projection.

这篇关于ARKit – Transform Matrix 中的不同列代表什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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