Jump to content
• Advertisement

# Matrix multiply does not work...

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

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

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

##### Share on other sites
Quote:
 Original post by JonConleyThe 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

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12
• Advertisement

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633664
• Total Posts
3013237
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!