在哪里可以找到所有变换矩阵字段的解释?
我在苹果的一些文档中看到,CALayer 的变换属性背后的矩阵具有 m14、m21、m22 等字段。 我还记得大约一两个月前我看到过一张解释这些字段的表格。 我费了很大劲才找到它。 有人知道来源吗?
I've seen in some document from apple that the matrix behind a CALayer's transform property has fields like m14, m21, m22 and so on. I also remember that I saw a table that explains those fields, about one or two months ago. I had a hard time trying to find it. Anybody knows a source?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该结构如下所示:
这只是一个用于变换 4 个向量的 4x4 变换矩阵。 它可用于表示任意数量的线性变换。 请参阅这篇有关此类矩阵的维基百科文章。 这些元素中的大多数不能真正独立解释,但有些可以。 例如,m41、m42 和 m43 表示 3 空间中的平移。 例如,如果您将一个点乘以这个矩阵:
那么它将将该点向 +X 平移 1,向 +Y 平移 2 个单位,向 +Z 平移 3 个单位。
请注意,该点必须表示为 4 个向量,其中第 4 个元素为 1。另请注意,该向量本身实际上是一个矩阵,并且该矩阵的格式与维基百科关于变换矩阵的文章中描述的格式不同。 这是因为一个点通常由单列 4 行矩阵表示,然而,Apple 将它们表示为 4 列单行矩阵。 这意味着您在维基百科文章中看到的任何变换矩阵都需要先转置,然后才能在 iPhone 上使用,才能正常工作。
另一个例子是缩放变换:
它将把点的所有坐标加倍,因此 (1, 2, 3) 将变为 (2, 4, 6)。 其他变换,例如旋转和透视投影,在视觉上更难以识别。
以下是有关转换的更多信息苹果。 Apple 提供了一系列实用程序转换来生成这些矩阵,请参阅 此链接。 他们实际上并没有讨论 CATransform3DMakeRotation 背后的数学原理,但此链接讨论了。
That struct looks like this:
This is simply a 4x4 transform matrix used to transform 4-vectors. It can be used to represent any number of linear transforms. See this wikipedia article on this type of matrix. Most of those elements can't really be interpreted independantly, but some can. For example m41, m42, and m43 represent a translation in 3-space. So for example if you multiply a point by this matrix:
Then it will translate that point by 1 toward +X, 2 units toward +Y, and 3 toward +Z.
Note that the point must be represented as a 4 vector with the 4th element being 1. Also note that this vector is actually a matrix itself and the format of this matrix differs from the one described in the wikipedia article on transform matrices. This is because a point is usually represented by a single column, 4 row matrix, however, Apple represents them as 4 column, single row matrices. This means that any transform matrix you see in the wikipedia article needs to be transposed before using it on the iPhone for it to work correctly.
Another example is a scaling transform:
It will double all of the coordinates of your point, so (1, 2, 3) will become (2, 4, 6). Other transforms, like rotations and perspective projections are more difficult to recognize on sight.
Here is more info on transforms from Apple. A bunch of utility transforms are provided by Apple for generating these matrices, see this link. They don't actually discuss the math behind CATransform3DMakeRotation, but this link does.