Hi, 

this time I solved or better got arround the following Problem, which might
be interesting tough.

I needed some Code to extract the rotation-part from a transformation Matrix
as a Quaternion. The following Code-parts are part of a project I´m
currently working on.

The following V1 Code gives obviously the wrong result for the "rot" Matrix.

V2 and V3 are working as expected, but i think they internaly also use the
matrix::factor() function. Thats what I found interesting.

Maybe someone could give me a hint, what i have done wrong in V1.

These results were produced by the CVS Version from 29.08.2004 with .NET
2003

Regards,

Andreas




--- V1 ---

const OSG::Matrix matrix(0,1,0,46,-1,0,0,42,0,0,1,0,0,0,0,1);
OSG::Quaternion quat;

OSG::Matrix rot;
OSG::Vec3f scale;
OSG::Matrix scaleaxis;
OSG::Vec3f trans;
OSG::Matrix proj;

matrix.factor(rot,scale,scaleaxis,trans,proj);
quat.setValue(rot);

std::cout << "Matrix: " << std::endl;
std::cout << matrix << std::endl;
std::cout << rot << std::endl;
std::cout << quat << std::endl;

--- V1 Output ---

Matrix:
   0.000    1.000    0.000   46.000
  -1.000    0.000    0.000   42.000
   0.000    0.000    1.000    0.000
   0.000    0.000    0.000    1.000

   1.000    0.000    0.000    0.000
   0.000    1.000    0.000    0.000
   0.000    0.000    1.000    0.000
   0.000    0.000    0.000    1.000

       0 0 0 1

--- V1 End ---



--- V2 ---

const OSG::Matrix matrix(0,1,0,46,-1,0,0,42,0,0,1,0,0,0,0,1);

OSG::Quaternion quat;
OSG::Quaternion quat2;
OSG::Vec3f scale;
OSG::Vec3f trans;

matrix.getTransform(trans,quat,scale,quat2);

std::cout << "Matrix: " << std::endl;
std::cout << matrix << std::endl;
std::cout << quat << std::endl;

--- V2 Output ---

Matrix:
   0.000    1.000    0.000   46.000
  -1.000    0.000    0.000   42.000
   0.000    0.000    1.000    0.000
   0.000    0.000    0.000    1.000

       0 0 -0.707 0.707

--- V2 End ---


--- V3 ---

const OSG::Matrix matrix(0,1,0,46,-1,0,0,42,0,0,1,0,0,0,0,1);

OSG::Quaternion quat;

quat.setValue(matrix);

std::cout << "Matrix: " << std::endl;
std::cout << matrix << std::endl;
std::cout << quat << std::endl;

--- V3 Output ---

Matrix:
   0.000    1.000    0.000   46.000
  -1.000    0.000    0.000   42.000
   0.000    0.000    1.000    0.000
   0.000    0.000    0.000    1.000

       0 0 -0.707 0.707

--- V3 End ---





-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to