Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock GetXYZInfrontOfVehicle(vehid,Float:distance,&Float:x,&Float:y,&Float:z)
- {
- new Float:Quaternion[4];
- new Float:transformationmatrix[4][4];
- GetVehicleRotationQuat(vehid, Quaternion[0], Quaternion[1], Quaternion[2], Quaternion[3]);
- new Float:xx = Quaternion[0] * Quaternion[0];
- new Float:xy = Quaternion[0] * Quaternion[1];
- new Float:xz = Quaternion[0] * Quaternion[2];
- new Float:xw = Quaternion[0] * Quaternion[3];
- new Float:yy = Quaternion[1] * Quaternion[1];
- new Float:yz = Quaternion[1] * Quaternion[2];
- new Float:yw = Quaternion[1] * Quaternion[3];
- new Float:zz = Quaternion[2] * Quaternion[2];
- new Float:zw = Quaternion[2] * Quaternion[3];
- transformationmatrix[0][0] = 1 - 2 * ( yy + zz );
- transformationmatrix[0][1] = 2 * ( xy - zw );
- transformationmatrix[0][2] = 2 * ( xz + yw );
- transformationmatrix[0][3] = 0.0;
- transformationmatrix[1][0] = 2 * ( xy + zw );
- transformationmatrix[1][1] = 1 - 2 * ( xx + zz );
- transformationmatrix[1][2] = 2 * ( yz - xw );
- transformationmatrix[1][3] = 0.0;
- transformationmatrix[2][0] = 2 * ( xz - yw );
- transformationmatrix[2][1] = 2 * ( yz + xw );
- transformationmatrix[2][2] = 1 - 2 * ( xx + yy );
- transformationmatrix[2][3] = 0;
- transformationmatrix[3][0] = 0;
- transformationmatrix[3][1] = 0;
- transformationmatrix[3][2] = 0;
- transformationmatrix[3][3] = 1;
- GetVehiclePos(vehid,x,y,z);
- z +=( -1 * transformationmatrix[0][1] + transformationmatrix[0][3])*distance;
- y +=( -1 * transformationmatrix[1][1] + transformationmatrix[1][3])*distance;
- x +=( -(-1 * transformationmatrix[2][1] + transformationmatrix[2][3]))*distance;
- }
Advertisement
Add Comment
Please, Sign In to add comment