arView.session.currentFrame.camera.transform 和 arview.cameraTransform 有什么区别? [英] What is the difference between arView.session.currentFrame.camera.transform and arview.cameraTransform?
问题描述
我在 RealityKit 中将来自相机的旋转应用于实体时偶然发现了这一点.我想我必须做一些矩阵数学才能从 arView.session.currentFrame.camera.transform
矩阵获得欧拉角,但是从 arview.cameraTransform.rotation
检索旋转成功了(在此处找到).>
那么:这两个矩阵有什么区别,应该在什么时候使用哪个?
您的第一个示例是变换矩阵
,它定义了相机在世界坐标中的旋转/平移.
打开 var 变换:simd_float4x4 { get }
您的第二个示例是一种特殊类型的变换矩阵
.
public var cameraTransform: Transform { get }//或者@MainActor var cameraTransform: Transform { get }
苹果的定义:
<块引用>请注意,Transform
是一种特殊类型,它不支持可以由通用 4x4 矩阵表示的所有转换.从 4x4 矩阵设置 Transform
是一种有损操作.它可能会导致某些转换(例如剪切)被丢弃!
但是,在某些情况下,cameraTransform
是比 transform
更方便的属性.
I stumbled upon this while applying rotation from the camera onto an entity in RealityKit. I thought I have to do some matrix math to gain the euler angles from arView.session.currentFrame.camera.transform
matrix, but retrieving the rotation from arview.cameraTransform.rotation
did the trick (found here).
So: What is the difference of both matrices and when should be used which?
Your first sample is the transform matrix
that defines the camera’s rotation/translation in world coordinates.
open var transform: simd_float4x4 { get }
Your second sample is a specialized type of the transform matrix
.
public var cameraTransform: Transform { get }
// or
@MainActor var cameraTransform: Transform { get }
Apple's definition:
Note that
Transform
is a specialized type that does not support all transformations that can be represented by a general 4x4 matrix. Setting theTransform
from a 4x4 matrix is a lossy operation. It may result in certain transformations (such as shearing) being dropped!
However, in some situations cameraTransform
is a more convenient property than transform
.
这篇关于arView.session.currentFrame.camera.transform 和 arview.cameraTransform 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!