Re: Given Latitude & Longitude calculate sphere coordinates in global space?
# Re: Given Latitude & Longitude calculate sphere coordinates in global space?

**Subject**: **Re: Given Latitude & Longitude calculate sphere coordinates in global space?**
- From: Jose Commins <email@hidden>
- Date: Fri, 25 Jun 2004 03:33:37 +0100

On 24 Jun 2004, at 23:48, Dan Herman wrote:

Websearch for "ECEF lat-lon conversion" or something similar should get

you going.

(In a prior life I wrote the nav software for an america's cup boat, go

figure...)

I guess writing the software was plain sailing. I saw that race
reported by a news anchor who had vast resources at his disposal - the
news team really pushed the boat out on that one.

Dan

On Jun 23, 2004, at 12:06 PM, Hisaoki Nishida wrote:

I have been trying to figure out the global coordinates of a location

on a surface of a sphere from a given set of latitude and longitude. I

know little of trigonometry, and I beleive with proper knowledge of it

this is a problem easily figured out. But I don't, and I would

appreciate some help by means of practical code.

I have a rendered textured sphere (earth) using gluSphere() with 64

segments each. I have the latitude and longitude of a location on

earth, and from that information I want to calculate its position in

global coordinates (the origin (0.0, 0.0, 0.0) is at the core of the

earth, with radius 1.0).

You can suppose that the greenwich meridian is facing the front, at

(0.0, 0.0, 1.0). No tilting of the earth for the sake of simplicity.

<snip>

-Yuki

_______________________________________________

Following on from Dan, note that a sphere's equation (hope I get this
right or else what am I doing on this list :oP ) is r = x^2 + y^2 + z^2
; so if your radius is 1.0, it is 1.0 = x^2 + Y^2 + z^2 . To invert
that for a quick, fast and dirty solution we have:

z = sqrt(1.0 - x^2 + y^2) - replace your lat/long (scaled) for X and
Y, and it should do the trick. It's not earth-accurate, though,
depends what you want to do:

Personally I use WGS84 for my world coordinate system (in another
project); here's a really good explanation, if you want to go the way
of full-earth-mapping-accuracy, to map onto an earth-type shape (this
is something I can't even begin to remember, so it's taken from

http://mathforum.org):

Date: 12/08/2001 at 11:07:30

From: Doctor Fenton

Subject: Re: GPS conversion

Dear M.S.,

Thanks for writing to Dr. Math.

I'm assuming that "altitude" in your question refers to "altitude

above the reference ellipsoid." If you are obtaining your altitude

from a GPS receiver, I believe that this would be the correct

interpretation. Many altitude specifications are "altitude above mean

sea level," however, and this can make a difference of up to nearly

100 meters. You would have to get information on the height of the

mean sea level surface (called the "geoid") relative to the reference

ellipsoid in the area of interest. The defining document for WGS84

(World Geodetic System 1984 - the Department of Defense geodetic

coordinate system used by GPS) gives a geoid map showing contours of

geoid height and a table of geoid heights on a latitude-longitude

grid.

The basic formulas for converting from latitude, longitude, altitude

(above reference ellipsoid) to Cartesian ECEF are given in the

Astronomical Almanac in Appendix K. They depend upon the following

quantities:

a the equatorial earth radius

f the "flattening" parameter ( = (a-b)/a ,the ratio of the

difference between the equatorial and polar radii to a;

this is a measure of how "elliptical" a polar cross-section

is).

The eccentricity e of the figure of the earth is found from

e^2 = 2f - f^2 , or e = sqrt(2f-f^2) .

For WGS84,

a = 6378137 meters

(1/f) = 298.257224

(the reciprocal of f is usually given instead of f itself, because the

reciprocal is so close to an integer)

Given latitude (geodetic latitude, not geocentric latitude!), compute

1

C = ---------------------------------------------------

sqrt( cos^2(latitude) + (1-f)^2 * sin^2(latitude) )

and

S = (1-f)^2 * C .

Then a point with (geodetic) latitude "lat," longitude "lon," and

altitude h above the reference ellipsoid has ECEF coordinates

x = (aC+h)cos(lat)cos(lon)

y = (aC+h)cos(lat)sin(lon)

z = (aS+h)sin(lat)

The Almanac also gives an iterative procedure for the inverse

conversion from ECEF to Lat/lon/alt, although there is a method due

to Bowring that may be better, and the Almanac also gives a reference

to a closed form (non-iterative) method due to Borkowski.

If you need any further information, please write us again.

- Doctor Fenton, The Math Forum

http://mathforum.org/dr.math/
--

The day Apple holds a majority share is the day I buy PC.

_______________________________________________

mac-opengl mailing list | email@hidden

Help/Unsubscribe/Archives:

http://www.lists.apple.com/mailman/listinfo/mac-opengl
Do not post admin requests to the list. They will be ignored.