Hi Ronald,

I've done a review of your changes, merged and tested them and all
look sound. I've also adapted your suggested changes to
computeLocalToWorld*() methods so that compute the local reference
frame is done in a separate method and then shared between the two
computeLocalToWorld implmentations.  This should reduce the potential
for bugs to slip into the what would have been duplicated code paths.
The code looks like:


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);

    localToWorld.makeTranslate(X,Y,Z);
    computeCoordinateFrame(latitude, longitude, localToWorld);
}

inline void EllipsoidModel::computeLocalToWorldTransformFromXYZ(double
X, double Y, double Z, osg::Matrixd& localToWorld) const
{
    double  latitude, longitude, height;
    convertXYZToLatLongHeight(X,Y,Z,latitude,longitude,height);

    localToWorld.makeTranslate(X,Y,Z);
    computeCoordinateFrame(latitude, longitude, localToWorld);
}

inline void EllipsoidModel::computeCoordinateFrame(double latitude,
double longitude, osg::Matrixd& localToWorld) const
{
    // 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;

    // set matrix
    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];
}

I've done my own preliminary testing that suggests it's OK, but I'd
appreciate a quick review as a sanity check before checking in.
Complete modified file attached.

Cheers,
Robert.

Attachment: CoordinateSystemNode
Description: Binary data

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to