fork download
  1. // Code is under the zlib license (same as Irrlicht)
  2. // Written by Michael Zeilfelder
  3. //
  4. // Search bug in: http://i...content-available-to-author-only...e.net/forum/viewtopic.php?f=7&t=50620
  5.  
  6. #include <irrlicht.h>
  7. #include <cassert>
  8.  
  9. using namespace irr;
  10. using namespace core;
  11.  
  12. #ifdef _MSC_VER
  13. #pragma comment(lib, "Irrlicht.lib")
  14. #endif
  15.  
  16. core::vector3df anotherConversion(const quaternion& q)
  17. {
  18. irr::f32 test = q.X*q.Y + q.Z*q.W;
  19. if (test > 0.499) { // singularity at north pole
  20. return core::vector3df(2 * atan2(q.X,q.W), PI/2.f, 0);
  21. }
  22. if (test < -0.499) { // singularity at south pole
  23. return core::vector3df(-2 * atan2(q.X,q.W), - PI/2.f, 0);
  24. }
  25. irr::f32 sqx = q.X*q.X;
  26. irr::f32 sqy = q.Y*q.Y;
  27. irr::f32 sqz = q.Z*q.Z;
  28. return core::vector3df(atan2(2.f*q.Y*q.W-2.f*q.X*q.Z,
  29. 1.f - 2.f*sqy - 2.f*sqz), asin(2.f*test),
  30. atan2(2.f*q.X*q.W-2.f*q.Y*q.Z , 1.f - 2.f*sqx - 2.f*sqz));
  31. }
  32.  
  33. int main(int argc, char *argv[])
  34. {
  35. quaternion q1,q2;
  36. q1.set(core::vector3df(0, 90, 0) *DEGTORAD);
  37. q2.set(core::vector3df(0, 91, 0) *DEGTORAD);
  38. core::vector3df e1, e2;
  39. q1.toEuler(e1);
  40. e1 *= RADTODEG;
  41. q2.toEuler(e2);
  42. e2 *= RADTODEG;
  43. core::vector3df e3(anotherConversion(q2));
  44. e3 *= RADTODEG;
  45.  
  46. return 0;
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:22: fatal error: irrlicht.h: No such file or directory
 #include <irrlicht.h>
                      ^
compilation terminated.
stdout
Standard output is empty