Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Thrump

power of matrix math...

This topic is 6485 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

When I first got into 3d graphics, matrix math seemed liked an unneccessary complexity. Why multiply the point by a translation matrix, when you can just add 3.5 to x? Well, here''s my character animation operations that have to be applied each frame (in order)... apply hierarchy to model (1 op) get initial position required for animation (4 ops) apply shape rotation (3*n ops) where n is depth in hierarchy(up to 7) apply root animation pos (1 op) apply mirror(makes right-handed animation left-handed) (1 op) animation splice (4*n ops) where n is # of animations spliced trans to origin (nice to start at 0,0,0) (1 op) rot to nearest 90 degrees (1 op) scale model (1 op) apply orientation (make y up vector) (1 op) apply slide (1 op) apply local pos/rot matrix (2 ops) Well, that''s good enough I guess. So, if I have 5 animations spliced together, that makes 50+ operations for each vertex in the hand (depth of 7 in hierarchy). With matrices, you can combine that into 1 matrix, meaning instead of doing 50+ operations, you only do 1 matrix*vector application. Now that I think of it, most of those rotations above have 3 matrics each. So that pushes it to 70? operations in just one matrix X vector operation. Needless to say, matrices make this feasible in real-time. Anyway, just wanted to count how many matrices I was cramming into 1, and then thought I''d share it with you all.

Share this post


Link to post
Share on other sites
Advertisement
Actually using matrices simply makes it easier for humans to understand. It really doesn''t matter if you put the values in a four by four array or into a structure or made them seperate parameters into a function. You still have to do the same work to apply the transformation.

Share this post


Link to post
Share on other sites
I''m not sure I understand your reasoning. I''m talking about how you can store up lots of transformations in one matrix, then once you have it you can apply it to all the points you want, without having to recalculate everything. How do you do that without them?

Share this post


Link to post
Share on other sites
I think 4x4 matrices are used because of the hardware. Theres lots of logig chips, which has 4x4 memory array (standard), so I think that''s why all transformations are processed with matrix.
(10 years of electronics...)

Share this post


Link to post
Share on other sites
You both have valid points, and I think they are both reasons that matrices are used. I''m wondering if my point is valid? Does anybody agree that this is 1 reason that matrices are used? (maybe not THE reason... )

Share this post


Link to post
Share on other sites
My point is that when you actually apply the transformation you are simply evaluating a set of equations. A matrix is simply a convention for representing those equations. The multiplications and additions still have to be performed. If you have specific hardware support then much of that can be done in parallel and the use of a matrix and matrix operations is telling the hardware how to break it into parallel operations. With the Pentium III there is not specific support for matrices. You have to code a series of multiplications and additions to calculate a cross product. It is easier to remember the rules for calculating a cross product and how to properly assign values to the elements of the transformation matrix. You could memorize or write down those equations and acheive the same result just as effeciently in the absence of specific hardware support.

Share this post


Link to post
Share on other sites
I think I''m understanding you, but I''m not sure. What I mean is, if you have 3 vertices you want to translate, rotate, then translate, using just the equations you would have to first apply the translate, then apply the rotation, then apply the last translation, to all 3 points, or 9 operations. If you do it with matrices, you make the matrix once (3 operations), then apply it 3 times (3 operations). Yes, the matrix operations are much more complicated than the equations would be, but, in a totally crazy example of applying 1,000,000 tranformations on 1,000,000 vertices, you would have to do 1,000,000,000,000 small equations, compared to just 2,000,000 matrix operations. Am I right? Is my reasoning sound? I''m new to this stuff so I''m not sure.

Share this post


Link to post
Share on other sites
don''t worry, thrump, i agree w/ you.

like, if something is oriented under like 6 different translations/rotations, instead of transforming all 10000 vertices by these 6 equations, it''s only transforming them by one that is the accumulation of the 6.

it''s definitely faster, so long as there''s more than a few vertices transformed by the same transformation, including heirarchies.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have no name that you may call me. I am merely Succinct.
~Succinct Demos Online~

-(Drop me a line here n''at)-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks Succinct! I knew I wasn''t crazy.

Share this post


Link to post
Share on other sites
You are making an invalid assumption that you must perform the transformations in series if you do not use a matrix. Any series of transformations can be represented by a single transformation. Just the same as you can take the cross product of two transformation matrices before you enter a loop you can calculate the values needed for a single set of three equations to acheive the same result before you enter the loop. A matrix makes it easy. Alternatively you could take the equations for calculating (X'', Y'', Z'') from (X, Y, Z) and substitute them in the equations for calculating (X'''', Y'''', Z'''') from (X'', Y'', Z''). Now you have an equation for calculating (X'''', Y'''', Z'''') from (X, Y, Z). Many of the terms of that can be evaluated indepentant of the value of (X, Y, Z). Those can be evaluated before you loop through the vertices. If you do enough of those you can recognize the pattern and use it without any knowledge of cross products. I believe that is how the definition of a cross product was arrived at. People recognized that this pattern occurs many times, gave it name and used it as tool in solving complex systems of equations.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!