• Advertisement
Sign in to follow this  

why using Matrices all the time ?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement


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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement