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
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
Torque Owner Arkadiusz Dymek
cheers,
Arkadesh