Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
ev0lution - 13.08.2010
NOTE: This release requires SA-MP 0.3b, (minimum RC1) currently in Release Candidate testing.
Quaternion Converter
Convert GetVehicleRotationQuat angles to XYZ!
What is it?
Quaternion Converter is a simple include which provides functions to convert a quaternion set (most commonly used in GetVehicleRotationQuat) to XYZ. (yaw, pitch and roll)
How do I use it?
Copy the include to your includes directory.
Include the "quaternion.inc" file in any scripts which you would like to use these functions in. (with "#include <quaternion>")
What am I allowed to do with it?
Quaternion Converter is licensed under the GNU General Public License. Please see COPYING in the download package, or
http://www.gnu.org/licenses/gpl.html.
Where can I download it?
http://www.megaupload.com/?d=BGXYITTT (1.0.0 @ 13/08/10)
Please abide by the terms of the license!
Function list
Код:
stock QuaternionToYawPitchRoll(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:x,&Float:y,&Float:z)
Takes the quaternion values specified by
quat_w,
quat_x,
quat_y and
quat_z, then converts them into roll, pitch and yaw (respectively) and saves them into the variables specified by
x,
y and
z.
Код:
stock QuaternionGetRoll(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:roll)
Takes the quaternion values specified by
quat_w,
quat_x,
quat_y and
quat_z, then converts them into roll (respectively) and saves them into the variables specified by
roll.
Код:
stock QuaternionGetPitch(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:pitch)
Takes the quaternion values specified by
quat_w,
quat_x,
quat_y and
quat_z, then converts them into pitch and saves them into the variables specified by
pitch.
Код:
stock QuaternionGetYaw(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:yaw)
Takes the quaternion values specified by
quat_w,
quat_x,
quat_y and
quat_z, then converts them into yaw and saves them into the variable specified by
yaw.
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Stepashka - 13.08.2010
must live simply!!!
PHP код:
stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) {
new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
return 1;
}
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
DANGER1979 - 25.08.2010
pawn Код:
stock ConvertNonNormaQuatToEuler(Float: qw, Float: qx, Float:qy, Float:qz,
&Float:heading, &Float:attitude, &Float:bank)
{
new Float: sqw = qw*qw;
new Float: sqx = qx*qx;
new Float: sqy = qy*qy;
new Float: sqz = qz*qz;
new Float: unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
//если normalised, - один, в противном случае - показатель коррекции
new Float: test = qx*qy + qz*qw;
if (test > 0.499*unit)
{ // singularity at north pole - особенность на северном полюсе
heading = 2*atan2(qx,qw);
attitude = 3.141592653/2;
bank = 0;
return 1;
}
if (test < -0.499*unit)
{ // singularity at south pole - особенность на южном полюсе
heading = -2*atan2(qx,qw);
attitude = -3.141592653/2;
bank = 0;
return 1;
}
heading = atan2(2*qy*qw - 2*qx*qz, sqx - sqy - sqz + sqw);
attitude = asin(2*test/unit);
bank = atan2(2*qx*qw - 2*qy*qz, -sqx + sqy - sqz + sqw);
return 1;
}
pawn Код:
stock GetVehicleRotation(vehicleid,&Float:heading, &Float:attitude, &Float:bank)
{
new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
ConvertNonNormaQuatToEuler(quat_w,quat_x,quat_z,quat_y, heading, attitude, bank);
bank = -1*bank;
return 1;
}
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
nuriel8833 - 26.08.2010
Good Job!
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
gesior7 - 05.09.2010
Your code, DANGER1979 works really nice with SA-MP objects. = )
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Babul - 09.12.2010
i believe, heres a multiplication needed instead of addidion: (quat_w+quat_z)
Код:
x = atan2(2*((quat_x*quat_y)+(quat_w*quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Falco-Ger - 27.04.2012
can u add something for this?
https://sampforum.blast.hk/showthread.php?tid=292795
anyway, megaupload is down
edit: requesting answer
Respuesta: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
[Vector] - 27.04.2012
Sorry for my ignorance, but what can I do with this?
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
MP2 - 28.04.2012
Find out the angles (X+Y) of a vehicle.
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Falco-Ger - 30.04.2012
can anyone post the code here since megaupload is down?
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Face9000 - 30.04.2012
09/12/2010
...
Re: Quaternion Converter - Convert GetVehicleRotationQuat angles to XYZ [1.0.0|13/08/10] -
Falco-Ger - 01.05.2012
what's the matter?
does anyone have that or a similar code then post it here please.
should just contain the functions from the original include and be working
thank you very much