[osg-users] ECEF orientation - roll acts as yaw

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Fri Aug 21 07:35:22 PDT 2015


Hi community,

I am aware from the search I did through the archive that some might
resolved this and have it working - I am trying a simple thing, to move the
camera on an ellipsoid using geodetic coordinates and euler angles (NED
alike). All works, but the roll, rotation around Vec3(0,1,0) acts as
changing its heading.

Here some snippets:

<snip>
double lat = 36.9268;
double lon = -75.9845;
double alt = 5608.62;
static double heading = 0.0;
static double pitch = 0.0;
static double roll = 0.0;

osg::Vec3d euler(heading, pitch+osg::DegreesToRadians(90.0), roll);

roll += osg::DegreesToRadians(1.0);

osg::Matrixd mx = toMatrix(
0.0,0.0,0.0,
osg::RadiansToDegrees(euler.x()), osg::RadiansToDegrees(euler.y()),
osg::RadiansToDegrees(euler.z())
);

osg::EllipsoidModel em;
osg::Matrixd l2w;
em.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(lat),
osg::DegreesToRadians(lon), alt, l2w);

viewer->getView(0)->getCamera()->setViewMatrix(osg::Matrixd::inverse(mx *
l2w));
....
....
osg::Matrixd toMatrix(double x, double y, double z, double h, double p,
double r)
{
osg::Matrixd mxR;
mxR.makeRotate(osg::DegreesToRadians(r), osg::Vec3(0, 1, 0));
osg::Matrixd mxP;
mxP.makeRotate(osg::DegreesToRadians(p), osg::Vec3(1, 0, 0));
osg::Matrixd mxH;
mxH.makeRotate(osg::DegreesToRadians(-h), osg::Vec3(0, 0, 1));
osg::Matrixd mxT;
mxT.makeTranslate(osg::Vec3(x, y, z));

return (mxR*mxP*mxH*mxT);
}


</snip>


Any clue? Thanks a bunch for any input!!!!

Cheers,
Nick

-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150821/7aa262c4/attachment-0002.htm>


More information about the osg-users mailing list