--- Paul Fotheringham <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I was just looking at the latest source code for
> osg::Matrix::getScale and was puzzled by the
> indexing.
> It looks like the vectors being assembled are the
> columns not the rows. Surely, if OSG matrices are
> row-major, then  these should be rows as the
> multiplication will be SR for scale S and rotation
> R?
> 
> I notice that the original code submitted on this
> list
> did indeed assemble the rows and not the columns but
> this has been swapped round when the patch was made.
> Why is this?
> 
> Apologies if I've got something screwed up in my
> head
> about this ;) Thanks.
> 
> Paul Fotheringham
> 

OK, no-one has commented on this so here's some code
that, to my mind, proves there's a problem.


#include <iostream>
using std::cout;
using std::endl;

#include <osg/MatrixTransform>
using osg::Vec3;
using osg::Matrix;

Vec3 altGetScale( const Matrix& mat )
{
    const Vec3 x_vec( mat(0,0), mat(0,1), mat(0,2) );
    const Vec3 y_vec( mat(1,0), mat(1,1), mat(1,2) );
    const Vec3 z_vec( mat(2,0), mat(2,1), mat(2,2) );

    return Vec3( x_vec.length(),
                 y_vec.length(),
                 z_vec.length() );
}

int main()
{
    const Matrix    scale( Matrix::scale( 1., 2., 3. )
);
    const Matrix rotation( Matrix::rotate( 1., 0.1,
0.4, 0.7 ) );

    const Matrix SR( scale * rotation );

    const Vec3 osgScales( SR.getScale() );
    const Vec3 altScales( altGetScale( SR ) );

    cout << "OSG Scaling: ( " << osgScales.x()
                      << ", " << osgScales.y()
                      << ", " << osgScales.z()
                      << " )" << endl;
    cout << "Alt Scaling: ( " << altScales.x()
                      << ", " << altScales.y()
                      << ", " << altScales.z()
                      << " )" << endl;

    return 0;
}



                
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre. http://uk.security.yahoo.com
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to