将变换矩阵拆分为正交矩阵和尺度矩阵

发布于 2024-11-18 03:49:14 字数 123 浏览 1 评论 0原文

如果我有一个来自缩放、平移和旋转变换的矩阵。我想把这个矩阵分成两个矩阵。一种是旋转+平移矩阵,另一种是缩放矩阵。

因为我想计算正确的法线向量变换,所以我只需要正交矩阵来计算表面法线向量

有什么想法吗?

If I have a matrix from scale, translate, and rotation transform. I want to split this matrix to two matrix. One is rotation+translation matrix, the other is scale matrix.

Because I want to compute the correct normal vector transform, so I only need orthogonal matrix to do the computation for surface normal vector

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流绪微梦 2024-11-25 03:49:14

如果我有一个来自缩放、平移和旋转变换的矩阵。我想把这个矩阵分成两个矩阵。一种是旋转+平移矩阵,另一种是缩放矩阵。

我假设你所说的这个矩阵是一个 4x4 矩阵,被一些人广泛使用,另一些人广泛鄙视,第四行是 0,0,0,1。

我将导致这两个操作“缩放”和“旋转+平移”。请注意:这些操作不可交换。缩放 3 向量,然后旋转/平移该缩放向量会产生与颠倒运算顺序所得到的结果不同的结果。

情况1,操作为“旋转+平移”,然后“缩放”。
令 SR=S*R,其中 S 是具有正对角线元素的 3x3 对角矩阵(缩放矩阵),R 是 3x3 正交旋转矩阵。矩阵 SR 的行将彼此正交,但列将不正交。比例因子是矩阵 SR 的行范数的平方根。

算法:
给定 4x4 矩阵 A,生成 4x4 缩放矩阵 S、4x4 旋转+平移矩阵 T

A = [  SR(3x3)  Sx(3x1) ]
    [   0(1x3)     1    ]
  1. 将 A 划分为 3x3 矩阵 SR 和 3 向量 Sx,如上所示。
  2. 构造缩放矩阵S。前三个对角元素是矩阵SR的行向量范数;最后一个对角线元素是 1。
  3. 通过将 A 的每一行除以相应的比例因子来构造 4x4 旋转+平移矩阵 T。

情况2,操作为“缩放”,然后“旋转+平移”。
现在考虑RS=R*S 的情况。这里 A 的列将彼此正交,但行将不正交。在这种情况下,比例因子是矩阵 RS 的列范数的平方根。

算法:
给定 4x4 矩阵 A,生成 4x4 旋转+平移矩阵 T、4x4 缩放矩阵 S

A = [  RS(3x3)  x(3x1) ]
    [   0(1x3)    1    ]
  1. 将 A 划分为 3x3 矩阵 RS 和 3 向量 x,如上所示。
  2. 构造缩放矩阵S。前三个对角元素是矩阵RS的列的向量范数;最后一个对角线元素是 1。
  3. 通过将 A 的每一行除以相应的比例因子来构造 4x4 旋转+平移矩阵 T。

如果缩放不均匀(例如,将 x 缩放 2、y 缩放 4、z 缩放 1/2),您可以通过查看上面 3x3 矩阵的行和列与 1 的内积来判断运算顺序。其他。最后缩放(我的情况 1)意味着行内积将非常接近于零,但列内积将不为零。首先扩展(我的案例 2)可以扭转这种情况。如果缩放是均匀的,则无法区分哪种情况。你需要提前知道。

If I have a matrix from scale, translate, and rotation transform. I want to split this matrix to two matrix. One is rotation+translation matrix, the other is scale matrix.

I'm assuming this matrix you are talking about is a 4x4 matrix that is widely used by some, widely despised by others, with the fourth row being 0,0,0,1.

I'll cause these two operations "scale" and "rotate+translate". Note well: These operations are not commutative. Scaling a 3-vector and then rotating/translating this scaled vector yields a different result than you would get by reversing the order of operations.

Case 1, operation is "rotate+translate", then "scale".
Let SR=S*R, where S is a 3x3 diagonal matrix with positive diagonal elements (a scaling matrix) and R is a 3x3 orthonormal rotation matrix. The rows of matrix SR will be orthogonal to one another, but the columns will not be orthogonal. The scale factors are the square root of the norms of the rows of the matrix SR.

Algorithm:
Given 4x4 matrix A, produce 4x4 scaling matrix S, 4x4 rotation+translation matrix T

A = [  SR(3x3)  Sx(3x1) ]
    [   0(1x3)     1    ]
  1. Partition A into a 3x3 matrix SR and a 3 vector Sx as depicted above.
  2. Construct the scaling matrix S. The first three diagonal elements are the vector norms of the rows of matrix SR; the last diagonal element is 1.
  3. Construct the 4x4 rotation+translation matrix T by dividing each row of A by the corresponding scale factor.

Case 2, operation is "scale", then "rotate+translate".
Now consider the case RS=R*S. Here the columns of A will be orthogonal to one another, but the rows will not be orthogonal. In this case the scale factors are the square root of the norms of the columns of the matrix RS.

Algorithm:
Given 4x4 matrix A, produce 4x4 rotation+translation matrix T, 4x4 scaling matrix S

A = [  RS(3x3)  x(3x1) ]
    [   0(1x3)    1    ]
  1. Partition A into a 3x3 matrix RS and a 3 vector x as depicted above.
  2. Construct the scaling matrix S. The first three diagonal elements are the vector norms of the columns of matrix RS; the last diagonal element is 1.
  3. Construct the 4x4 rotation+translation matrix T by dividing each row of A by the corresponding scale factor.

If the scaling is not uniform (e.g., scale x by 2, y by 4, z by 1/2), you can tell the order of operations by looking at the inner products of the rows and columns of the upper 3x3 matrix with one another. Scaling last (my case 1) means the row inner products will be very close to zero but the column inner products will be non zero. Scaling first (my case 2) reverses the situation. If the scaling is uniform there is no way to tell which case is which. You need to know beforehand.

剑心龙吟 2024-11-25 03:49:14

只是一个想法 -

  • 将矩阵乘以单位向量 (1/sqrt(3),1/sqrt(3),1/sqrt(3))
  • 检查之后向量的长度乘法,
  • 按该值的倒数缩放矩阵。现在您有了一个正交矩阵,
  • 可以使用您找到的比例创建一个新的比例矩阵。

Just an idea -

  • Multiply the matrix by the unit vectors (1/sqrt(3),1/sqrt(3),1/sqrt(3)),
  • check how the length of the vector after the multiplication,
  • scale the matrix by the reciprocal of that value. Now you have an orthogonal matrix
  • create a new scale matrix with the scale you found.
绅刃 2024-11-25 03:49:14
  1. 删除平移以获得 3x3 矩阵
  2. 通过 SVD 执行极分解
  1. Remove the translation to get a 3x3 matrix
  2. Perform the polar decomposition via SVD.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文