Wojtek,
Your absolutely right about the orthogonality relation.
This could be easily fixed with:
---------------------------------------------------------------
inline void
EllipsoidModel::computeLocalToWorldTransformFromLatLongHeight(double latitude,
double longitude, double height, osg::Matrixd& localToWorld) const
{
double X, Y, Z;
convertLatLongHeightToXYZ(latitude,longitude,height,X,Y,Z);
// Compute up vector
osg::Vec3d up ( cos(longitude)*cos(latitude),
sin(longitude)*cos(latitude), sin(latitude));
// Compute east vector
osg::Vec3d east (-sin(longitude), cos(longitude), 0);
// Compute north vector = outer product up x east
osg::Vec3d north = up ^ east;
// Create matrix
localToWorld.makeTranslate(X,Y,Z);
localToWorld(0,0) = east[0];
localToWorld(0,1) = east[1];
localToWorld(0,2) = east[2];
localToWorld(1,0) = north[0];
localToWorld(1,1) = north[1];
localToWorld(1,2) = north[2];
localToWorld(2,0) = up[0];
localToWorld(2,1) = up[1];
localToWorld(2,2) = up[2];
}
inline void EllipsoidModel::computeLocalToWorldTransformFromXYZ(double X,
double Y, double Z, osg::Matrixd& localToWorld) const
{
double latitude;
double longitude;
double altitude;
convertXYZToLatLongHeight(X,Y,Z,latitude,longitude,altitude);
// Compute up vector
osg::Vec3d up ( cos(longitude)*cos(latitude),
sin(longitude)*cos(latitude), sin(latitude));
// Compute east vector
osg::Vec3d east (-sin(longitude), cos(longitude), 0);
// Compute north vector = outer product up x east
osg::Vec3d north = up ^ east;
// Create matrix
localToWorld.makeTranslate(X,Y,Z);
localToWorld(0,0) = east[0];
localToWorld(0,1) = east[1];
localToWorld(0,2) = east[2];
localToWorld(1,0) = north[0];
localToWorld(1,1) = north[1];
localToWorld(1,2) = north[2];
localToWorld(2,0) = up[0];
localToWorld(2,1) = up[1];
localToWorld(2,2) = up[2];
}
---------------------------------------------------------------
Cheers,
Ronald van Maarseveen
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=14757#14757
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org