How to represent a 4x4 matrix rotation?

前端 未结 3 1524
伪装坚强ぢ
伪装坚强ぢ 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: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.

提交回复
热议问题