Game Development Community

Vector math - inaccuracy or am I making sth wrong?

by Arkadiusz Dymek · in Torque Game Engine · 08/11/2006 (6:47 pm) · 1 replies

Hello

I'm bit lost doing my math code.
I've got two vectors rotated by pitch and yaw:

%eyeVector = $player.getEyeVector();

%transMatrix0 = MatrixCreateFromEuler(0 SPC $shotPitch SPC 0);
%transMatrix1 = MatrixCreateFromEuler(0 SPC 0 SPC -$shotYaw);

Now, if I rotate my eyeVector by any of the above matrices

%rotatedVector = MatrixMulVector(%transMatrix0, %eyeVector);
or
%rotatedVector = MatrixMulVector(%transMatrix1, %eyeVector);

and use %rotatedVector as %muzzleVector in projectile creation code it looks like shots are getting perfectly where I want them - on given axis depending on matrix I've used for calculations.

But as soon as I combine matrices:
%transMatrix = MatrixMultiply(%transMatrix1, %transMatrix0);
%rotatedVector = MatrixMulVector(%transMatrix, %eyeVector);
it looks I get some inaccuracy on one of axes - depending on order I combine them in.
Is there any way to make it hit accurately where I want?

cheers,
Arkadesh

#1
08/12/2006 (5:09 am)
On second thought - now it looks that it's expected behaviour as vector has fixed length, and its end moves in circle around me. But I still cannot get formula that would allow me to do get results I want. (Basically I'm trying to create function that would allow me to point at (x, y) cursor point and shoot there. So far I've found what pitch and yaw delta are needed to move haircross x and y pixels, but that doesn't work when moving both coordinates - any ideas?). Probably I'm missing something quite simple...

cheers,
Arkadesh