Hi all,
What about adding a isIdentity() method with an epsilon in osg::Matrix? I
sometimes had things like "m * inverse(m)" (across many lines of code, of
course), resulting in "almost" identity matrices. I coded something like this
for the moment, but this may be useful to others:
/// Returns true if a matrix is 'almost' identity, meaning that the difference
between each value and the corresponding identity value is less than an epsilon
value.
bool isIdentityEquivalent(const osg::Matrix & mat, osg::Matrix::value_type
epsilon=1e-6)
{
return osg::equivalent(mat(0,0), 1, epsilon) && osg::equivalent(mat(0,1),
0, epsilon) && osg::equivalent(mat(0,2), 0, epsilon) &&
osg::equivalent(mat(0,3), 0, epsilon) &&
osg::equivalent(mat(1,0), 0, epsilon) && osg::equivalent(mat(1,1),
1, epsilon) && osg::equivalent(mat(1,2), 0, epsilon) &&
osg::equivalent(mat(1,3), 0, epsilon) &&
osg::equivalent(mat(2,0), 0, epsilon) && osg::equivalent(mat(2,1),
0, epsilon) && osg::equivalent(mat(2,2), 1, epsilon) &&
osg::equivalent(mat(2,3), 0, epsilon) &&
osg::equivalent(mat(3,0), 0, epsilon) && osg::equivalent(mat(3,1),
0, epsilon) && osg::equivalent(mat(3,2), 0, epsilon) &&
osg::equivalent(mat(3,3), 1, epsilon);
}
Cheers,
Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org