In 2D or 3D, matrix transformations are used for rotation, scaling, and sheering. However, when it comes to movement, should I go out of my way to use and implement scalar/vector movement, or just stick to matrix translations? Thanks.

  • 1
    \$\begingroup\$ Did you have any issue with that? Or is it just premature optimization? \$\endgroup\$ – Vaillancourt Dec 29 '15 at 19:13

This depends on some pipeline details, but generally we're not just translating objects, our engines need to handle objects that are translated, rotated, and scaled, and often need to apply camera view & perspective transforms to them too.

All of these transformations can be concatenated and applied with a single matrix multiplication, so it usually makes sense just to fold translation into that matrix. There's no incremental cost to translating that way, and any object, no matter how it's transformed, can be handled identically (rather than having one path for purely-translated objects and another for everything else)

If you're making a game where nothing ever scales, rotates, skews, or perspective projects, then you might make some efficiency gains by translating alone through vector addition without a matrix — but in exchange for pretty onerous restrictions on what your engine can do. For most projects, the matrix multiply is worth the flexibility it offers.

Even where a matrix is used, it's still conventional to store the translation, rotation, and scale information separately, so that when any of those change the matrix can be rebuilt from scratch, rather than continuously modified, keeping rounding errors from accumulating & causing drift.


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.