How to find intersection at horizon?

classic Classic list List threaded Threaded
4 messages Options
Ivo K. Ivo K.
Reply | Threaded
Open this post in threaded view
|

How to find intersection at horizon?

Hi all,

When I click outside the earth ellipsoid displayed on the screen I have x and y coordinates in screen space of the clicked point.
I can easilly convert x,y into workdspace using the current view's projection, view and window matrices. But I need to find out an intersection with the earth which is orthogonal from the earth horizon to the clicked point. Visualy for the user this means the closes point on earth to that clicked point in the sky above.
I hope that I made myself clear and someone could help me, please excuse my english.

Best Regards,
Ivo
Ivo K. Ivo K.
Reply | Threaded
Open this post in threaded view
|

Re: How to find intersection at horizon?

Actually the problem is how to find the position of the earth horizon in the z buffer when I convert x,y from screenspace to x,y,z in world space.
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: How to find intersection at horizon?

Hi Ivo,

Are you trying to find the location on the earth under the mouse?  If so, you can use the viewer->computeIntersections method to compute the XYZ location on the earth (see the OpenSceneGraph osgpick example).  The XYZ that you get will be in geocentric coordinates if you are using a globe.  If you need those converted to latitude,longitude and height you can find the osg::CoordinateSystemNode using the findTopMostNodeOfType function in osgEarth's FindNode header.

osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(myGlobe);

You can then compute the lat/lon/height at your intersection point using the CSNS's ellipsoid model by doing something like this:

osg::EllipsoidModel* em = csn->getEllipsoidModel();
if (em)
{
   double latitude, longitude, height;
   em->convertXYZToLatLongHeight(x, y, z, latitude, longitude, height);
}

Your latitude and longitude will be in radians and your height will be in meters.

Thanks,

Jason

On Sat, Sep 26, 2009 at 10:13 AM, Ivo K. (via Nabble) - No Reply <[hidden email]> wrote:
Actually the problem is how to find the position of the earth horizon in the z buffer when I convert x,y from screenspace to x,y,z in world space.


View message @ http://n2.nabble.com/How-to-find-intersection-at-horizon-tp3717501p3717506.html
To start a new topic under osgEarth, email [hidden email]
To unsubscribe from osgEarth, click here.


Ivo K. Ivo K.
Reply | Threaded
Open this post in threaded view
|

Re: How to find intersection at horizon?

Hi Jason,

Thanks for your reply.
I know how to find the XYZ in earth coordinates when the mouse click is *over* the earth.
But I need to find out something different: when the mouse click is outside the earth globe, i.e. in the empty space outside the earth elliposid. In that case I need to find the XYZ of the closest point on the horizon. Please check the image I attached, hope it makes it clear:

The intersection of the point on the horizon that is orthogonal to the earth on the horizon and ends at the mouse click. I.e. I don't know how to specify the Z of the mouse clicked point when intersecting with the center of the earth (0, 0, 0).