daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bullet/LinearMath/btVector3.h>
  2. #include <bullet/LinearMath/btQuaternion.h>
  3. #include <cstdio>
  4. #define SQR2 0.707106781
  5. int main(){
  6.   btVector3 loc(1,0,0);
  7.   btQuaternion rot(SQR2,0,0,SQR2);
  8.   printf("R (%f,%f,%f,%f)\n",
  9.     rot.getW(),
  10.     rot.getX(),
  11.     rot.getY(),
  12.     rot.getZ()
  13.   );
  14.   btQuaternion arot(rot.getW(),-rot.getX(),-rot.getY(),rot.getZ());
  15.   //The above screws it up..?
  16.   //btQuaternion arot(SQR2,-0,-0,SQR2);//does it right
  17.   printf("R^-1 (%f,%f,%f,%f)\n",
  18.     arot.getW(),
  19.     arot.getX(),
  20.     arot.getY(),
  21.     arot.getZ()
  22.   );
  23.   btQuaternion locq(0,loc.x(),loc.y(),loc.z());
  24.   btQuaternion res = rot*locq*arot;
  25.   printf("Now (%f,%f,%f,%f)\n",
  26.     res.getW(),
  27.     res.getX(),
  28.     res.getY(),
  29.     res.getZ()
  30.   );
  31. return 1;
  32. }
  33.  
  34.  
  35.  
  36. OUTPUT:
  37.  
  38. $ ./a.out
  39. R (0.707107,0.707107,0.000000,0.000000)
  40. R^-1 (0.000000,0.707107,-0.707107,-0.000000)
  41. Now (0.500000,0.500000,0.500000,-0.500000)
RAW Paste Data
Top