Sign in to follow this  
SteveDeFacto

Matrix multiply does not work...

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this