SceneKit 转换值,它们是如何实现的?

SceneKit transform values, how are they implemented?

Apple's SceneKit documentation表示物体的变换矩阵由旋转、位置和尺度信息组成。然而,变换矩阵是一个 4x4 矩阵,最后一列是 0,0,0,1。这些值到底是什么,是否对该矩阵有更详细的解释?比如whichcolumns/rows代表什么,为什么有4行,最后一列是干嘛用的?

示例代码:

for t in 0...3 {
    print("\t")
    for n in frame.camera.transform[t] {
        print(String(format: "%10.1f", n),terminator: "");
    }
}

输出:

   0.1      -0.7       0.7       0.0    
   1.0       0.2      -0.1       0.0    
  -0.1       0.7       0.7       0.0    
   0.3      -0.1       0.0       1.0

我很确定这是 CATransform3D:

https://developer.apple.com/documentation/quartzcore/catransform3d

这是 Apple 臭名昭著的愚蠢文档历史上最愚蠢的 "documentation"。

试试这个,从 wayback 机器上,当他们过去至少更深入地谈论事情时......有点:https://web.archive.org/web/20111010140734/http://developer.apple.com/library/mac/#/web/20111012014313/https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layers.html

m34 是整个矩阵中最有趣的一个,因为它通常被称为负责 perspective.

这里是关于 Core Animation 的最佳文章之一,解释了这种转换的某些方面:http://www.thinkandbuild.it/introduction-to-3d-drawing-in-core-animation-part-1/