Hi All!
currently I am working a lot with the current OpenSG 1.8 CVS version.
I am using the methods Matrix::getTransform and Matrix::setTransform,
and I found a problem with matrices containing non-uniform scale
values in combination with rotations.
In short the following pseudo code does not work as expected:
(1) Matrix mtx = {...};
(2) mtx.getTransform(trans, rot, scale, scaleOri);
(3) mtx.setTransform(trans, rot, scale, scaleOri);
(4) mtx.getTransform(trans, rot, scale, scaleOri);
are not invariant, that is I don't get the same results neither
for scale and scaleOri in (2) and (4) nor for mtx in (1) and (3).
I have attached a small test-program that should demonstrate
the effect. The invariance shows in a permutation of scaling
values as returned in (2) and (4).
I had a look at the source code, but I have to confess that it
would take a substantial amount of time to understand the
decomposition, so maybe the original author is still working on
OpenSG and could have a look. Althogh I am not sure whether its
the getTransform or the setTransform method which causes the
trouble, I suspect the getter to be problematic due the code
complexity.
Maybe there is already a fix in OpenSG 2.0?
Regards,
Kaya
#include <OpenSG/OSGGLUT.h>
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
#include <OpenSG/OSGSimpleSceneManager.h>
OSG_USING_NAMESPACE
int main(int argc, char **argv)
{
osgInit(argc,argv);
osg::Matrix m;
m[0][0] = 0.571;
m[1][0] = 0.71;
m[2][0] = 0.208;
m[3][0] = -0.71;
m[0][1] = 0;
m[1][1] = -1.041;
m[2][1] = 1.041;
m[3][1] = 1.041;
m[0][2] = 0.227;
m[1][2] = -1.786;
m[2][2] = -0.524;
m[3][2] = 1.872;
osg::Vec3f trans;
osg::Quaternion rot;
osg::Vec3f scale;
osg::Quaternion scalOri;
m.getTransform(trans, rot, scale, scalOri);
std::cerr << "t1: trans = [" << trans << "]" << std::endl;
std::cerr << " rot = [" << rot << "]" << std::endl;
std::cerr << " scale = [" << scale << "]" << std::endl;
std::cerr << " sori = [" << scalOri << "]" << std::endl;
m.setTransform(trans, rot, scale, scalOri);
m.getTransform(trans, rot, scale, scalOri);
std::cerr << "t2: trans = [" << trans << "]" << std::endl;
std::cerr << " rot = [" << rot << "]" << std::endl;
std::cerr << " scale = [" << scale << "]" << std::endl;
std::cerr << " sori = [" << scalOri << "]" << std::endl;
m.setTransform(trans, rot, scale, scalOri);
m.getTransform(trans, rot, scale, scalOri);
std::cerr << "t3: trans = [" << trans << "]" << std::endl;
std::cerr << " rot = [" << rot << "]" << std::endl;
std::cerr << " scale = [" << scale << "]" << std::endl;
std::cerr << " sori = [" << scalOri << "]" << std::endl;
return 0;
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users