1. Matrix*vector= how to?

i'm trying to multiply a vector by a matrix the problem is that doesn't
perform any rotation on the vector !

argh... i'm blocked in the creation of my little 3d game ( Space invader 2003)

i've this formula to multiply a vector by a matrix
| A B C D | | x1 x2 x3 x4 x5 | | A.x1+B.y1+C.z1+D A.x2+B.y2+C.z2+D ... |
| E F G H | . | y1 y2 y3 y4 y5 | = | E.x1+F.y1+G.z1+H E.x2+F.y2+G.z2+H ... |
| I J K L | | z1 z2 y3 y4 z5 | | I.x1+J.y1+K.z1+L I.x2+J.y2+K.z2+L ... |
| M N O P | | 1 1 1 1 1 | | M.x1+N.y1+O.z1+P M.x2+N.y2+O.z2+P ... |

so i've created this func

void M4x4multV3(Vector3f *result,Vector3f *in,float *m)
{

result->x=(m[0]*in->x)+(m[4]*in->y)+(m[8]*in->z)+m[12];
result->y=(m[1]*in->x)+(m[5]*in->y)+(m[9]*in->z)+m[13];
result->z=(m[2]*in->x)+(m[6]*in->y)+(m[10]*in->z)+m[14];
}

/*
m is a 4x4 matrix OpenGL order
Vector3f is define like this
typedef struct
{
float x,y,z;
}Vector3f;
*/

2. Re: Matrix*vector= how to?

in fact that work the problem was not here

3. Re: Matrix*vector= how to?

hello

be aware of a potential snafu: you're not computing the w component of your vector. This may not be a problem for your work, but just keep it in mind if you start using funky psycho matricies!

cheers
John

4. Re: Matrix*vector= how to?

okay!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•