Advertisement

Use of identity matrix?

Started by June 22, 2000 03:56 AM
10 comments, last by Muzzafarath 24 years, 6 months ago
Can anyone please tell me what the use of the identity matrix is? Multiplying a matrix with the identity matrix just gives the first matrix... Then why would you want to multiply with the identity matrix at all...? It will just take up precious clock cycles It would be like writing int x = 5; x = x; x will be equal to x... I see no point in the identity matrix. /. Muzzafarath Mad House Software
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
You''re quite right in pointing out that there''s no point in multiplying by the identity matrix.

In scalar arithmetic, there''s no point in multiplying by 1 - but no one ever questions the wisdom of having a value of 1 because we intuitively understand why it is useful.

Uniary values can be particularly useful in simplifying mathematical equations, which in turn can make for more efficient and robust code. A trivial scalar example:

x + ax + bx = x(1 + a + b)

So instead of performing two multiplies and one addition, we can perform one multiply and two additions. And the more complex the equation, the more potential for benefit. Now a similar matrix example (N and M have the same dimensions ;->):

A + NA + MA = A(I + N + M)

Trust me - matrix additions are much faster than matrix multiplications. So now you know why the identity matrix is a Good Thing. Similar things can be said about the zero matrix - where would scalar arithmetic be without a zero?
Advertisement
Asking "what''s the use for the Identity matrix" is just like asking "what is the use for the number 1.".
Mathematically, they amount to exactly the same thing.
Multiplying by it yields no difference, adding does.

And by the way, most OpenGL implementations are smart enough to bypass matrices if you set them to the Identity matrix, so for instance, if you Identity the projection matrix, it will skip the entire projection stage.
Just an example to show you why it''s useful.


Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
quote: Original post by MadKeithV

Asking "what's the use for the Identity matrix" is just like asking "what is the use for the number 1.".
Mathematically, they amount to exactly the same thing.
Multiplying by it yields no difference, adding does.

And by the way, most OpenGL implementations are smart enough to bypass matrices if you set them to the Identity matrix, so for instance, if you Identity the projection matrix, it will skip the entire projection stage.
Just an example to show you why it's useful.

Give me one more medicated peaceful moment..
~ (V)^/) /<é!t/-/ ~


I read in some tutorial that "multiplying with the identity matrix is useful because every matrix multiplied with the identity matrix comes out the same". I just can't see why that's useful, but I do see when the identity matrix is useful in your projection example.

I re-phrase my question: why is it useful to multiply a matrix with the identity matrix?

/. Muzzafarath
Mad House Software

Edited by - Muzzafarath on June 22, 2000 7:19:01 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
quote: Original post by Muzzafarath
why is it useful to multiply a matrix with the identity matrix?



Multiplying with the identity matrix isn''t usefull (tutorials don''t say always the truth), but it''s useful for other things, Osc explained it.


Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Just pointing out a small error in Osc equations :

A + NA + MA = A(I + N + M) // Wrong

A + NA + MA = (I + N + M)A // Right

It doesn''t look like there is a difference, but believe me there is. With matrices you have to be careful in what order you multiply them.

Another use for the identity matrix is when you want to invert a matrix. When inverting you are in fact solving the following equation:

A-1A = AA-1 = I





- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Cheers, WitchLord! That really was a silly error...

Still, that''s the price for taking a 5 minute helldesk call in the middle of writing an equation. (no, that''s not a typo ;->)

I remember doing some work on using the identity matrix to find the inverse of a given matrix a while ago. The details are now a haze, but I recall that this is a very efficient process and helps to solve numerous problems the require a matrix inverse, such as some common problems in 3D graphics.

quote: Original post by Muzzafarath
It would be like writing

int x = 5;
x = x;

x will be equal to x... I see no point in the identity matrix.



I''m not so sure about x will be equal to x.. I read in the C Faq that the results are undefined if the variable is being referenced and dereferenced.

Eh eh, try this one, an error I had in my engine just the other day:
float x = 1.0f;
int y = x/0.1f;
y = .... 9!!!!!!!!!


Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
quote: Original post by Void

I'm not so sure about x will be equal to x.. I read in the C Faq that the results are undefined if the variable is being referenced and dereferenced.



Perhaps, but IRL, x will equal x

- Muzzafarath

Mad House Software
The Field Marshals

Edited by - Muzzafarath on June 23, 2000 5:30:37 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall

This topic is closed to new replies.

Advertisement