更改以行为主的4x4转换矩阵的``惯用性'' [英] Change 'handedness' of a Row-major 4x4 transformation matrix

查看:67
本文介绍了更改以行为主的4x4转换矩阵的``惯用性''的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以行为主的4x4转换矩阵格式的转换和旋转坐标数据.

I have transformation and rotation coordinate data that is in a Row-major 4x4 transformation matrix format.

Ux Vx Wx Tx    
Uy Vy Wy Ty    
Uz Vz Wz Tz    
0  0  0  1

数据源和我需要发送的软件具有不同的手工坐标系.一个是左撇子,另一个是右手.

The source of the data and the software that I need to send it to have different handed coordinate systems. One is left-handed, the other right.

如何将矩阵从右手改为左手,反之亦然?我知道,对于变换而言,您可以仅反转Y轴,但是对于旋转而言,它似乎更复杂.

How can I change the matrix from right to left handed and vice versa? I understand that for transformations you can just invert the Y axis, but for rotations it seems more complex.

谢谢.

推荐答案

您可以通过翻转Y轴在两个坐标系之间转换向量.这等效于乘以矩阵:

You convert vectors between the two coordinate systems by flipping the Y axis. This is equivalent to multiplying by the matrix:

F = [ 1  0  0  0 ]
    [ 0 -1  0  0 ]
    [ 0  0  1  0 ]
    [ 0  0  0  1 ]

要在翻转的坐标空间中应用变换,可以翻转Y轴,应用变换,然后再次翻转Y轴以返回到原始坐标空间.写成矩阵乘法,看起来像:

To apply your transformation in the flipped coordinate space, you could flip the Y axis, apply your transform, and then flip the Y axis again to get back to the original coordinate space. Written as matrix multiplication, this looks like:

F*(M*(F*x))                [1]

(其中M是您的矩阵).好的,但这很浪费-现在我们有了三个矩阵乘法,而不是一个;幸运的是,矩阵乘法是关联的,所以我们重写:

(where M is your matrix). Ok, but that's wasteful -- now we have three matrix multiplies instead of one; fortunately, matrix multiplication is associative, so we re-write:

F*(M*(F*x)) = (FMF)*x

我们只需要计算矩阵FMF.对角矩阵的左乘法按对角线上的相应元素缩放另一个矩阵的行;右乘法缩放列.所以我们要做的就是否定第二行和第二列:

We just need to compute the matrix FMF. Left-multiplication by a diagonal matrix scales the rows of the other matrix by the corresponding elements on the diagonal; right-multiplication scales the columns. So all we need to do is negate the second row and column:

FMF = [ Ux -Vx  Wx  Tx ]
      [-Uy  Vy -Wy -Ty ]
      [ Uz -Vz  Wz  Tz ]
      [  0   0   0   1 ]

从您的评论看来,您可能实际上并不想转换回原始坐标系,在这种情况下,您可以简单地使用矩阵MF而不是FMF.

From your comment, it sounds like you may not actually want to convert back into the original coordinate system, in which case you could simply use the matrix MF instead of FMF.

[1]更一般地说,先进行变换,然后进行一些操作,然后再取消变换,这被称为共轭作用,并且通常采用F⁻¹MF的形式.碰巧我们的矩阵F是它自己的逆.

[1] More generally, doing a transform, followed by some operation, followed by undoing the transform is called acting by conjugation, and it usually has the form F⁻¹MF. It just happens that our matrix F is its own inverse.

这篇关于更改以行为主的4x4转换矩阵的``惯用性''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆