diff --git a/include/osg/CoordinateSystemNode b/include/osg/CoordinateSystemNode index be1828c6c..8a58e330a 100644 --- a/include/osg/CoordinateSystemNode +++ b/include/osg/CoordinateSystemNode @@ -180,8 +180,10 @@ inline void EllipsoidModel::computeLocalToWorldTransformFromXYZ(double X, double { localToWorld.makeTranslate(X,Y,Z); + // normalize X,Y,Z double inverse_length = 1.0/sqrt(X*X + Y*Y + Z*Z); + X *= inverse_length; Y *= inverse_length; Z *= inverse_length; @@ -191,21 +193,21 @@ inline void EllipsoidModel::computeLocalToWorldTransformFromXYZ(double X, double // Vx = |(-Y,X,0)| localToWorld(0,0) = -Y*inverse_length_XY; - localToWorld(1,0) = X*inverse_length_XY; - localToWorld(2,0) = 0.0; + localToWorld(0,1) = X*inverse_length_XY; + localToWorld(0,2) = 0.0; // Vy = /(-Z*X/(sqrt(X*X+Y*Y), -Z*Y/(sqrt(X*X+Y*Y),sqrt(X*X+Y*Y))| double Vy_x = -Z*X*inverse_length_XY; double Vy_y = -Z*Y*inverse_length_XY; double Vy_z = length_XY; inverse_length = 1.0/sqrt(Vy_x*Vy_x + Vy_y*Vy_y + Vy_z*Vy_z); - localToWorld(0,1) = Vy_x*inverse_length; + localToWorld(1,0) = Vy_x*inverse_length; localToWorld(1,1) = Vy_y*inverse_length; - localToWorld(2,1) = Vy_z*inverse_length; + localToWorld(1,2) = Vy_z*inverse_length; // Vz = (X,Y,Z) - localToWorld(0,2) = X; - localToWorld(1,2) = Y; + localToWorld(2,0) = X; + localToWorld(2,1) = Y; localToWorld(2,2) = Z; } diff --git a/src/osg/CoordinateSystemNode.cpp b/src/osg/CoordinateSystemNode.cpp index 87b4c5b9e..87bb76b1a 100644 --- a/src/osg/CoordinateSystemNode.cpp +++ b/src/osg/CoordinateSystemNode.cpp @@ -49,7 +49,7 @@ CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(double X, doub } else { - return Matrixd(); + return Matrixd::translate(X,Y,Z); } }