| | 414 | void testDecompose() |
| | 415 | { |
| | 416 | double angx = osg::DegreesToRadians(30.0); |
| | 417 | double angy = osg::DegreesToRadians(30.0); |
| | 418 | double angz = osg::DegreesToRadians(30.0); |
| | 419 | |
| | 420 | osg::Quat qx, qy, qz; |
| | 421 | qx.makeRotate(angx, osg::Vec3f (1.0f, 0.0f, 0.0f)); |
| | 422 | qy.makeRotate(angy, osg::Vec3f (0.0f, 1.0f, 0.0f)); |
| | 423 | qz.makeRotate(angz, osg::Vec3f (0.0f, 0.0f, 1.0f)); |
| | 424 | |
| | 425 | osg::Quat rotation = qx * qy * qz; |
| | 426 | |
| | 427 | osg::Matrixf matf; |
| | 428 | matf.makeRotate(rotation); |
| | 429 | |
| | 430 | printf ("Test - Matrix::decompos(), input rotation : %f %f %f %f\n", rotation._v[0], rotation._v[1], rotation._v[2], rotation._v[3]); |
| | 431 | |
| | 432 | osg::Vec3f transf; |
| | 433 | osg::Quat rotf; |
| | 434 | osg::Vec3f sclf; |
| | 435 | osg::Quat sof; |
| | 436 | matf.decompose (transf, rotf, sclf, sof); |
| | 437 | printf ("Matrixf::decomposef\n"); |
| | 438 | printf ("Translation : %f %f %f\n", transf.x(), transf.y(), transf.z()); |
| | 439 | printf ("Rotation : %f %f %f %f\n", rotf._v[0], rotf._v[1], rotf._v[2], rotf._v[3]); |
| | 440 | printf ("Scale : %f %f %f\n", sclf.x(), sclf.y(), sclf.z()); |
| | 441 | printf ("Scale Orientation: %f %f %f %f\n", sof._v[0], sof._v[1], sof._v[2], sof._v[3]); |
| | 442 | |
| | 443 | osg::Matrixd matd; |
| | 444 | matd.makeRotate(rotation); |
| | 445 | |
| | 446 | osg::Vec3f transd; |
| | 447 | osg::Quat rotd; |
| | 448 | osg::Vec3f scld; |
| | 449 | osg::Quat sod; |
| | 450 | matd.decompose (transd, rotd, scld, sod); |
| | 451 | printf ("Matrixd::decompose\n"); |
| | 452 | printf ("Translation : %f %f %f\n", transd.x(), transd.y(), transd.z()); |
| | 453 | printf ("Rotation : %f %f %f %f\n", rotd._v[0], rotd._v[1], rotd._v[2], rotd._v[3]); |
| | 454 | printf ("Scale : %f %f %f\n", scld.x(), scld.y(), scld.z()); |
| | 455 | printf ("Scale Orientation: %f %f %f %f\n", sod._v[0], sod._v[1], sod._v[2], sod._v[3]); |
| | 456 | |
| | 457 | osg::notify(osg::NOTICE)<<std::endl; |
| | 458 | } |
| | 459 | |