Advertisement
Guest User

Untitled

a guest
Mar 11th, 2012
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.08 KB | None | 0 0
  1. /*
  2.  *
  3.  * Quaternion Converter
  4.  * Allows simple conversion from quaternion angles (supplied by new SA-MP 0.3b functions) to yaw/pitch/roll
  5.  *
  6.  * NAME         Quaternion Converter
  7.  * AUTHOR       ev0lution
  8.  * FILE         quaternion.inc
  9.  * VERSION      1.0.0
  10.  * LICENSE      GNU General Public License (see below)
  11.  * COPYRIGHT    Copyright © 2010 ev0lution
  12.  *
  13.  *  This file is part of Quaternion Converter.
  14.  *
  15.  *  Quaternion Converter is free software: you can redistribute it and/or modify
  16.  *  it under the terms of the GNU General Public License as published by
  17.  *  the Free Software Foundation, either version 3 of the License, or
  18.  *  (at your option) any later version.
  19.  *
  20.  *  Quaternion Converter is distributed in the hope that it will be useful,
  21.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23.  *  GNU General Public License for more details.
  24.  *
  25.  *  You should have received a copy of the GNU General Public License
  26.  *  along with Quaternion Converter.  If not, see <http://www.gnu.org/licenses/>.
  27.  *
  28.  */
  29.  
  30. stock QuaternionToYawPitchRoll(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:x,&Float:y,&Float:z) {
  31.     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));
  32.     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));
  33.     z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
  34.     return 1;
  35. }
  36.  
  37. stock QuaternionGetRoll(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:roll) {
  38.     roll = 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));
  39.     return 1;
  40. }
  41.  
  42. stock QuaternionGetPitch(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:pitch) {
  43.     pitch = 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));
  44.     return 1;
  45. }
  46.  
  47. stock QuaternionGetYaw(Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z,&Float:yaw) {
  48.     yaw = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
  49.     return 1;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement