问题描述
ARAnchor
的 4x4 矩阵有 4 列.矩阵的第四列包含 x
、y
和 z
坐标的 3 个平移值.
我想知道其他 3 列代表什么?
在 3D 图形中,我们经常使用带有 16 个有用元素的 4
x4
矩阵.Identity 4
x4
矩阵如下:
在这 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 中列的索引为:0
、1
、2
、3
.
第四列(索引 3)用于翻译值:
var translation = matrix_identity_float4x4翻译.columns.3.x翻译.columns.3.y翻译.columns.3.z
您可以阅读我关于插图故事媒体上的 nofollow noreferrer">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?
In 3D Graphics we often use a 4
x4
Matrix with 16 useful elements. The Identity 4
x4
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 4
x4
Matrix
are located on the last column:
┌ ┐
| 1 0 0 tx |
| 0 1 0 ty |
| 0 0 1 tz |
| 0 0 0 1 |
└ ┘
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 中的不同列代表什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!