How to represent a 4x4 matrix rotation?

前端 未结 3 1497
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 17:51

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:

<
相关标签:
3条回答
  • 2021-02-05 18:19

    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
    
    0 讨论(0)
  • 2021-02-05 18:28

    It actually is really important what order you apply your rotations in.

    The order you want depends on what you want the rotations to do. For instance, if you are modeling an airplane, you might want to do the roll first (rotate along the long axis of the body), then the pitch (rotate along the other horizontal axis), then the heading (rotate along the vertical axis). This would be because, if you did the heading first, the plane would no longer be aligned along the other axes. Beyond that, you need to deal with your conventions: which of these axes correspond to X, Y, and Z?

    Generally, you only want to choose a particular rotation order for specific applications. It doesn't make much sense to define a generic "XYZrotation" object; typically, you will have generic transformations (i.e., matrices that can be any concatenation of rotations, translations, etc.) and various ways to get them (e.g., rotX, rotY, translate, scale...), plus the ability to apply them in a particular order (by doing matrix multiplication).

    If you want something that can only represent rotations and nothing else, you might consider quaternions (as anand suggests). However, you still need to decide which order to perform your rotations in, and, again, it doesn't really make sense to hardwire a required order for that.

    0 讨论(0)
  • 2021-02-05 18:28

    As an aside and if you're early enough in your development activities here, you might want to consider using quaternion rotation. It has a number of comparative advantages to matrix based approaches.

    0 讨论(0)
提交回复
热议问题