Jump to content
  • Advertisement
Sign in to follow this  
SteveDeFacto

Matrix multiply does not work...

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

This is the operator I made for my class:


AxMatrix44 AxMatrix44::operator * ( const AxMatrix44& in ) const
{
AxMatrix44 out;
out._11 = in._11 * _11;
out._12 = in._12 * _12;
out._13 = in._13 * _13;
out._14 = in._14 * _14;
out._21 = in._21 * _21;
out._22 = in._22 * _22;
out._23 = in._23 * _23;
out._24 = in._24 * _24;
out._31 = in._31 * _31;
out._32 = in._32 * _32;
out._33 = in._33 * _33;
out._34 = in._34 * _34;
out._41 = in._41 * _41;
out._42 = in._42 * _42;
out._43 = in._43 * _43;
out._44 = in._44 * _44;
return out;
}




It does not seem to be working right...

Share this post


Link to post
Share on other sites
Advertisement
Component by component multiplication is not what people typically refer to when talking about "matrix multiplication".

Read this:

http://en.wikipedia.org/wiki/Matrix_multiplication

Share this post


Link to post
Share on other sites
The reason it doesn't work is because you aren't multiplying matrix by matrix, you are only multiplying each component by the corresponding component.
(this is assuming _12 means row 1 column 2).
out._11 = _11*in._11 + _12*in._21 + _13*in._31 + _14*in._41;
out._12 = _11*in._12 + _12*in._22 + _13*in._32 + _14*in._42;
out._13 = _11*in._13 + _12*in._23 + _13*in._33 + _14*in._43;
out._14 = _11*in._14 + _12*in._24 + _13*in._34 + _14*in._44;

that gives you the top row of the final matrix.

Share this post


Link to post
Share on other sites
Quote:
Original post by JonConley
The reason it doesn't work is because you aren't multiplying matrix by matrix, you are only multiplying each component by the corresponding component.
(this is assuming _12 means row 1 column 2).
out._11 = _11*in._11 + _12*in._21 + _13*in._31 + _14*in._41;
out._12 = _11*in._12 + _12*in._22 + _13*in._32 + _14*in._42;
out._13 = _11*in._13 + _12*in._23 + _13*in._33 + _14*in._43;
out._14 = _11*in._14 + _12*in._24 + _13*in._34 + _14*in._44;

that gives you the top row of the final matrix.


Oh thank you!

Share this post


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

  • 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!