How to calculate the driving attitude on earth?

classic Classic list List threaded Threaded
3 messages Options
Mirro187 Mirro187
Reply | Threaded
Open this post in threaded view
|

How to calculate the driving attitude on earth?

This post was updated on .
CONTENTS DELETED
The author has deleted this message.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How to calculate the driving attitude on earth?

Do you want the direction? Maybe GeoMath::bearing() will help?
Glenn Waldron / Pelican Mapping
Mirro187 Mirro187
Reply | Threaded
Open this post in threaded view
|

Re: How to calculate the driving attitude on earth?

What's wrong with this code for the direction of travel?

osg::Vec3d vecFirst  = destPts.at(j - 1);//World coordinates of latitude and longitude
osg::Vec3d vecSecond = destPts.at(j);//World coordinates of latitude and longitude
//
osg::Vec3d v3dDir;
v3dDir = vecSecond - vecFirst;
v3dDir.normalize();
//
vecFirst  = vecFirst;
vecSecond = vecSecond;
//pos
osg::Vec3d pos = vecSecond;
//y axis
osg::Matrixd mat1;
osg::Vec3d v3dYAxis = osg::Vec3d(0, 1, 0);
mat1.makeRotate(v3dYAxis, v3dDir);
//z axis
osg::Vec3d v3dZAxis = mat1.preMult(osg::Vec3d(0, 0, 1));
v3dZAxis.normalize();
osg::Vec3d resPosNor;
osg::ref_ptr<osg::EllipsoidModel> em = new osg::EllipsoidModel();
if (em.valid())
{
        resPosNor = em->computeLocalUpVector(vec.x(),vec.y(),vec.z());
}
osg::Vec3d zDir = resPosNor;
zDir.normalize();
osg::Matrixd mat2;
osg::Matrixd mt;
if (v3dZAxis*zDir < 0)
{
        osg::Matrixd mt3;
        mt3.makeRotate(osg::PI, v3dDir);
        osg::Vec3d v3dZAxis = mat1.preMult(osg::Vec3d(0, 0, -1));
        v3dZAxis.normalize();
        mat2.makeRotate(v3dZAxis, zDir);
        mt = mat1*mt3*mat2;
}
else
{
        mat2.makeRotate(v3dZAxis, zDir);
        mt = mat1*mat2;
}
Quat quat, quat0;
quat.set(mt);