I am curious what is the best strategy to save 3d transformation of a model.

Here are the few choices I think about:

  • 4x4 matrix
  • 4x3 matrix(skip the bottom row of a 4*4 matrix)
  • Dual quaternions with a 3d scaling vector
  • 3x3 matrix with a 3d translation vector
  • 1
    \$\begingroup\$ I've seen all four used successfully. Whether one or another (or a fifth option) is better for your specific project will depend on what your specific needs are. Have you tried making a start with the one that makes the most intuitive sense to you? Have you encountered any problems with that approach that you'd like help solving? \$\endgroup\$ – DMGregory Jul 10 '18 at 11:36

There are two considerations here:

  1. What format do you need to export to your GPU for rendering (or to your physics engine for simulating)?

    This will usually be a matrix. You can decide whether it's worth keeping the last row/column separate or implicit, or if it's more convenient to store a full 4x4 explicitly.

  2. What format do you need for manipulating your objects each frame?

    Here, it's important to ensure you can handle many iterated transformation changes without distorting your values.

    If scale and rotation are both baked into a matrix, then you can't easily distinguish between deliberate scale changes and rounding errors accumulated through repeated rotations.

    So at minimum you'll want to separate your rotation and scale source values, so you can work with them independently (eg. as a quaternion and a vector, or a matrix and a vector) and combine them to the exported format (1) on demand without degradation.

    Translation could be combined into the rotation matrix without ambiguity, though you might find it simplest to keep all three parts independent and combine them only for the final result.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.