如何表示4x4矩阵旋转? [英] How to represent a 4x4 matrix rotation?

查看:343
本文介绍了如何表示4x4矩阵旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出x,y,z旋转矩阵的以下定义,如何将其表示为一个完整的矩阵?只需将x,y和&矩阵?

X旋转:

[1 0 0 0]
[0 cos(-X Angle) -sin(-X Angle) 0]
[0 sin(-X Angle) cos(-X Angle) 0]
[0 0 0 1]

Y旋转:

[cos(-Y Angle) 0 sin(-Y Angle) 0]
[0 1 0 0]
[-sin(-Y Angle) 0 cos(-Y Angle) 0]
[0 0 0 1]

Z旋转:

[cos(-Z Angle) -sin(-Z Angle) 0 0]
[sin(-Z Angle) cos(-Z Angle) 0 0]
[0 0 1 0]
[0 0 0 1] 

我有一个单独的旋转类,其中包含一个x,y,z浮点值,后来我将其转换为矩阵,以便与其他平移/缩放/旋转组合. >

从这里的答案来看,我可以假设如果我做类似的事情:

旋转旋转; rotation.SetX(45); rotation.SetY(90); rotation.SetZ(180);

那么,对于旋转应用哪个顺序实际上是非常重要的?还是可以安全地假设使用旋转类时,您是否接受它们以x,y,z顺序应用?

解决方案

是的,依次将三个矩阵相乘即可​​构成它们.

将乘法应用于矩阵的顺序将确定将旋转应用于点的顺序.

P × (X × Y × Z)     Rotations in X, Y, then Z will be performed
P × (Y × X × Z)     Rotations in Y, X, then Z will be performed
P × (Z × X × Y)     Rotations in Z, X, then Y will be performed

Given the following definitions for x,y,z rotation matrices, how do I represent this as one complete matrix? Simply multiply x, y, & matrices?

X Rotation:

[1 0 0 0]
[0 cos(-X Angle) -sin(-X Angle) 0]
[0 sin(-X Angle) cos(-X Angle) 0]
[0 0 0 1]

Y Rotation:

[cos(-Y Angle) 0 sin(-Y Angle) 0]
[0 1 0 0]
[-sin(-Y Angle) 0 cos(-Y Angle) 0]
[0 0 0 1]

Z Rotation:

[cos(-Z Angle) -sin(-Z Angle) 0 0]
[sin(-Z Angle) cos(-Z Angle) 0 0]
[0 0 1 0]
[0 0 0 1] 

Edit: I have a separate rotation class that contains an x, y, z float value, which I later convert to a matrix in order to combine with other translations / scales / rotations.

Judging from the answers here, I can assume that if I do something like:

Rotation rotation; rotation.SetX(45); rotation.SetY(90); rotation.SetZ(180);

Then it's actually really important as to which order the rotations are applied? Or is it safe to make the assumption that when using the rotation class, you accept that they are applied in x, y, z order?

解决方案

Yes, multiplying the three matrices in turn will compose them.

EDIT:

The order that you apply multiplication to the matrices will determine the order the rotations will be applied to the point.

P × (X × Y × Z)     Rotations in X, Y, then Z will be performed
P × (Y × X × Z)     Rotations in Y, X, then Z will be performed
P × (Z × X × Y)     Rotations in Z, X, then Y will be performed

这篇关于如何表示4x4矩阵旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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