Mark Aubin (aubin++at++mustang.engr.sgi.com)
Thu, 3 Jun 1999 22:06:36 -0700 (PDT)
/usr/share/Performer/src/lib/libpfdb/libpfdem/pfdem.c
This is a loader for a standard USGS DEM file. Included
is a function called WGS84_to_Cartesian() which does
the requested conversion in one direction. You can
probably figure out the other direction from this.
--Mark Aubin
aubin++at++sgi.com
PS - here's the function so you don't have to go looking:
/*
* This function converts geodetic coordinates (WGS-84 datum)
* to Cartesian coordinates (earth-centered, earth-fixed).
*
* Z-axis points toward the North Pole; X-axis is defined by
* the intersection of the plane defined by the prime meridian
* and the equatorial plane; Y-axis completes a right handed
* coordinate system by a plane 90 degrees east of the X-axis
* and its intersection with the equator.
*
* Note that the latitute and longitude values are expected
* to be in radians, other values are in meters!
*/
#define WGS84_ES 0.00669437999013 /* Eccentricity squared */
#define WGS84_EER 6378137.0 /* Ellipsoid equatorial radius (semi-major axis) */
void WGS84_to_Cartesian(double latitude, double longitude, double height,
double cartesian[3])
{
double coslat, sinlat;
double N; /* radius of vertical in prime meridian */
coslat = cos(latitude);
sinlat = sin(latitude);
N = WGS84_EER / sqrt(1.0 - WGS84_ES*sinlat*sinlat);
cartesian[0] = (N + height) * coslat * cos(longitude);
cartesian[1] = (N + height) * coslat * sin(longitude);
cartesian[2] = (N*(1.0 - WGS84_ES) + height) * sinlat;
}
On Jun 3, 5:05pm, Shankar N Swamy wrote:
> Subject: Re: xyz <--> lat/long
>
> "Digital Cartography for Computer Graphics" by Alan W. Paeth
> in "Graphics Gems" Edited by Andrew S. Glassner. Page 307.
>
> > sci wrote:
> >
> > Hi :
> >
> > Does anyone know where I can find the info about the math for xyz <--> lat/long
> > coordinate conversion?
> >
> > Thanks,
> >
> > sci
>
> --
>
>
> --------------------------------------------------------------------------
> shankar.n.swamy++at++boeing.com Shankar N. Swamy
> Computer Graphics & VR Research
> PHONE: (425) 865-4286 Mathematics & Computing Technology
> FAX : (425) 865-2965 Phantom Works, Boeing
> PO Box 3707 MS 7L-48, Seattle, WA 98124-2207
> ---------------------------------------------------------------------------
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>-- End of excerpt from Shankar N Swamy
This archive was generated by hypermail 2.0b2 on Thu Jun 03 1999 - 22:06:39 PDT