Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bullet/LinearMath/btVector3.h>
- #include <bullet/LinearMath/btQuaternion.h>
- #include <cstdio>
- #define SQR2 0.707106781
- int main(){
- btVector3 loc(1,0,0);
- btQuaternion rot(SQR2,0,0,SQR2);
- printf("R (%f,%f,%f,%f)\n",
- rot.getW(),
- rot.getX(),
- rot.getY(),
- rot.getZ()
- );
- btQuaternion arot(rot.getW(),-rot.getX(),-rot.getY(),rot.getZ());
- //The above screws it up..?
- //btQuaternion arot(SQR2,-0,-0,SQR2);//does it right
- printf("R^-1 (%f,%f,%f,%f)\n",
- arot.getW(),
- arot.getX(),
- arot.getY(),
- arot.getZ()
- );
- btQuaternion locq(0,loc.x(),loc.y(),loc.z());
- btQuaternion res = rot*locq*arot;
- printf("Now (%f,%f,%f,%f)\n",
- res.getW(),
- res.getX(),
- res.getY(),
- res.getZ()
- );
- return 1;
- }
- OUTPUT:
- $ ./a.out
- R (0.707107,0.707107,0.000000,0.000000)
- R^-1 (0.000000,0.707107,-0.707107,-0.000000)
- Now (0.500000,0.500000,0.500000,-0.500000)
Add Comment
Please, Sign In to add comment