diff --git a/examples/osgintersection/osgintersection.cpp b/examples/osgintersection/osgintersection.cpp index 1bf4b39c3..2a29fe4de 100644 --- a/examples/osgintersection/osgintersection.cpp +++ b/examples/osgintersection/osgintersection.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) es.setDatabaseCacheReadCallback(los.getDatabaseCacheReadCallback()); es.setStartPoint(bs.center()+osg::Vec3d(bs.radius(),0.0,0.0) ); - es.setEndPoint(bs.center()+osg::Vec3d(0.0,bs.radius(),0.0) ); + es.setEndPoint(bs.center()+osg::Vec3d(0.0,0.0,bs.radius()) ); es.computeIntersections(scene.get()); @@ -149,6 +149,7 @@ int main(int argc, char **argv) dhitr != dhl.end(); ++dhitr) { + std::cout.precision(10); std::cout<<" "<first<<" "<second<convertXYZToLatLongHeight(_startPoint.x(), _startPoint.y(), _startPoint.z(), latitude, longitude, height); + _startRadius = _startPoint.length() - height; + _startNormal.normalize(); + + // set up end point variables + _em->convertXYZToLatLongHeight(_endPoint.x(), _endPoint.y(), _endPoint.z(), latitude, longitude, height); + _endRadius = _endPoint.length() - height; + _endNormal.normalize(); + + osg::Vec3d normal = _startNormal ^ _endNormal; + normal.normalize(); + + _angleIncrement = 0.005; + + _radiusList.push_back(_startRadius); + _distanceList.push_back(0.0); + + osg::Matrixd rotationMatrix; + double angleBetweenStartEnd = acos( _startNormal * _endNormal ); + double prevRadius = _startRadius; + double distance = 0.0; + for(double angle = _angleIncrement; + angle < angleBetweenStartEnd; + angle += _angleIncrement) + { + rotationMatrix.makeRotate(angle, normal); + osg::Vec3d newVector = osg::Matrixd::transform3x3(_startPoint, rotationMatrix); + + _em->convertXYZToLatLongHeight(newVector.x(), newVector.y(), newVector.z(), latitude, longitude, height); + double newRadius = newVector.length() - height; + + double distanceIncrement = _angleIncrement * (newRadius + prevRadius) *0.5; + distance += distanceIncrement; + + _radiusList.push_back(newRadius); + _distanceList.push_back(distance); + + // osg::notify(osg::NOTICE)<<" newVector = "<