Finding Lat/Lon on a 3D Globe

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
JBJ
Posts: 1263
Joined: Fri Dec 12, 2008 6:20 pm UTC
Location: a point or extent in space

Finding Lat/Lon on a 3D Globe

Postby JBJ » Thu Jun 06, 2013 5:49 pm UTC

If I have a 3D globe that looks like this:
globe.png


How could I find the latitude/longitude from the x,y coordinates?
(x,y coords based on the green crosshair with 0,0 at the center).

In the example picture above, the visible edges of the globe are 195 pixels from the center on each axis, but the actual size will be different depending on the display. The width and height will always be the same. So if another value for the boundaries makes it easier to explain, feel free to substitute.

The globe will also be spinning and in different orientations (looking more on the northern/southern hemispheres). It doesn't have to be precise, but I'd like to be accurate within about 5 degrees or so (250-350 miles).

I can already determine the lat/lon at the centerpoint (0,0), so what would be great would be the relative angles on the sphere from the center position. In other words, always assume that the center is on lat 0.000, long 0.000. I can transpose from there.

Background: I'm working on this as a little side project for work as a fun little data visualization. It was inspired by and borrowed heavily from here:
http://www.smartjava.org/content/render ... be-threejs
and here:
http://www.chromeexperiments.com/globe

Thanks in advance for any help.
So, you sacked the cocky khaki Kicky Sack sock plucker?
The second cocky khaki Kicky Sack sock plucker I've sacked since the sixth sitting sheet slitter got sick.

User avatar
scarecrovv
It's pronounced 'double u'
Posts: 674
Joined: Wed Jul 30, 2008 4:09 pm UTC
Location: California

Re: Finding Lat/Lon on a 3D Globe

Postby scarecrovv » Thu Jun 06, 2013 7:25 pm UTC

Is this an orthographic or perspective projection?

http://en.wikipedia.org/wiki/3D_projection

It makes a difference. Orthographic would be easier. I think you might have a perspective projection, but it's hard to be sure from just the picture.

User avatar
JBJ
Posts: 1263
Joined: Fri Dec 12, 2008 6:20 pm UTC
Location: a point or extent in space

Re: Finding Lat/Lon on a 3D Globe

Postby JBJ » Thu Jun 06, 2013 8:11 pm UTC

It appears that it indeed was a perspective camera. I'm using the Three.js library, and looking at the documentation, I see that there is an alternative to use an Orthographic camera.
I just switched it around to use the orthographic camera and I get the following now:
globe2.png


I also added reference lines at 30 and 45 degrees (30 degrees only to the right of 0,0)
So now it looks like 30 degrees is halfway between the center and the visible edge. Can I now just use sin and cos to find the lat/lon?
So, you sacked the cocky khaki Kicky Sack sock plucker?
The second cocky khaki Kicky Sack sock plucker I've sacked since the sixth sitting sheet slitter got sick.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Finding Lat/Lon on a 3D Globe

Postby PM 2Ring » Fri Jun 07, 2013 7:46 am UTC

JBJ wrote:Can I now just use sin and cos to find the lat/lon?

Pretty much. For details, have a look at the draw() function in my animated globe JavaScript program that I posted in Coding: Fleeting Thoughts back in 2011.

User avatar
JBJ
Posts: 1263
Joined: Fri Dec 12, 2008 6:20 pm UTC
Location: a point or extent in space

Re: Finding Lat/Lon on a 3D Globe

Postby JBJ » Fri Jun 07, 2013 12:37 pm UTC

Excellent. Thanks to both for your help, I've got enough now to forge ahead.
So, you sacked the cocky khaki Kicky Sack sock plucker?
The second cocky khaki Kicky Sack sock plucker I've sacked since the sixth sitting sheet slitter got sick.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 8 guests