# why using Matrices all the time ?

This topic is 1511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I would like to ask you guys, why do I need use matrices all the time .

instead using Scale Matrix, I just multiple each componet direcly .

also about rotation , I can directly set the new Compontes without any Matrix at all .

##### Share on other sites

also about rotation , I can directly set the new Compontes without any Matrix at all .

This comment makes me wonder if you are talking about 2D rotation, or 3D rotation?

If you're talking about 2D, then I'm kinda with you. Matrices always feel like overkill for 2D for me and I rarely use them.

If you're talking about 3D, then matrices (particularly pre-concatenated ones like Brother Bob suggests) are your friend. It's always good to know when to drop to more direct manipulation in hotter sections of code though.

##### Share on other sites

As Brother Bob suggested, typically you aren't performing a single transformation.  For typical drawing of 3D objects you're going to have a local-space translation, local-space rotation, camera-space translation, camera-space rotation, and a perspective projection.  You may or may not also have some scaling in there.

If you try to do all of these individually, in isolation and without matrices the amount of per-vertex calculations required are going to mount up, and you'll be using a lot more memory to set the various factors.  What you want to do is concatenate all of these transforms on the CPU and send the single combined transform one-time-only, then have that transform apply to each vertex in the most efficient way possible.

A matrix will give you that, whereas other representations generally won't.  Multiplying a position by a matrix is just a series of 4 dot products, which is very GPU-friendly.

The exception might be if you're doing something very specific where you know you've got only a certain well-defined transform to apply and you know that you're never going to need anything more than a simpler representation.  Screen-aligned quads for 2D GUI work is one such example; otherwise for the general case just use a matrix.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633343
• Total Posts
3011434
• ### Who's Online (See full list)

There are no registered users currently online

×