Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wanted: Azimuth-Elevation <-> X-Y-Z coordinations formula

6,241 views
Skip to first unread message

Tim Stark

unread,
Nov 14, 1993, 12:19:55 PM11/14/93
to
All:

I am looking for algortihms that convert data between Azimuth-Elevation
and X-Y-Z coordination formulas. Does anyone have algorithms or formulas?
If so, I will appericate that. Thanks! I looked into my graphics books but
no luck. That is for nagivation or astronomy.

My project is writing nagivation-like Star Trek simulation.

-- Tim Stark

--
Timothy Stark Inet: tst...@clark.net
6130 Edsall Rd. #301 TDD: (703)212-9731 FAX: (703)212-7598
Alexandria, Va. 22304-5859 Voice: Via VA Relay Center (800)828-1140
"God bless you! - My friend, Washington DC. - The Most Deaf Population City!"

Paul Schlyter

unread,
Nov 14, 1993, 4:18:58 PM11/14/93
to
In article <2c5pbr$1...@clarknet.clark.net>, Tim Stark <tst...@clark.net> wrote:

> I am looking for algortihms that convert data between Azimuth-Elevation
>and X-Y-Z coordination formulas. Does anyone have algorithms or formulas?
>If so, I will appericate that. Thanks! I looked into my graphics books but
>no luck. That is for nagivation or astronomy.

That's easy! Suppose your X-axis points towards lon=lat=0, your Y-axis
towards lon=90 deg, lat=0, and your Z_axis towards lat=90 deg, then the
conversion goes like this (if the distance, r, is unimportant or unknown,
set it equal to one):

X = r * cos(lon) * cos(lat)
Y = r * sin(lon) * cos(lat)
Z = r * sin(lat)

And the other way it's:

r = sqrt( X*X + Y*Y + Z*Z )
lon = atan2( Y, X )
lat = asin( Z/r ) = atan2( Z, sqrt( X*X + Y*Y ) )

(the second formula for "lat = .." has the advantage of being accurate
also very close to 90 degrees)

The "atan2( Y, X )" is available as a library function in C and Fortran,
in other languages code it as:

if X > 0 then return atan( Y/X )
if X < 0 then return atan( Y/X ) +- pi (or 180 degrees)
if X = 0 and Y > 0 then return pi/2 (or 90 degrees)
if X = 0 and Y < 0 then return -pi/2 (or -90 degrees)

If both X and Y are exactly zero, the result of atan2(0,0) is really
undefined -- however it works well to set the result equal to zero in
such cases (think about it: what's the longitude of the North or South
Pole on Earth?)

Finally, should the division Y/X cause an arithmetic overflow, treat this
as if X was exactly zero.

--
---
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Nybrogatan 75 A, 6 tr, S-114 40 Stockholm, Sweden
InterNet: pau...@saaf.se

Ernst Schrama

unread,
Nov 14, 1993, 7:16:03 PM11/14/93
to
In article <2c67c2$3...@electra.saaf.se> pau...@electra.saaf.se (Paul Schlyter) writes:
>In article <2c5pbr$1...@clarknet.clark.net>, Tim Stark <tst...@clark.net> wrote:
>
>> I am looking for algortihms that convert data between Azimuth-Elevation
>>and X-Y-Z coordination formulas. Does anyone have algorithms or formulas?
>>If so, I will appericate that. Thanks! I looked into my graphics books but
>>no luck. That is for nagivation or astronomy.
>
>That's easy! Suppose your X-axis points towards lon=lat=0, your Y-axis
>towards lon=90 deg, lat=0, and your Z_axis towards lat=90 deg, then the
>conversion goes like this (if the distance, r, is unimportant or unknown,
>set it equal to one):
>
> X = r * cos(lon) * cos(lat)
> Y = r * sin(lon) * cos(lat)
> Z = r * sin(lat)
>
>And the other way it's:
>
> r = sqrt( X*X + Y*Y + Z*Z )
> lon = atan2( Y, X )
> lat = asin( Z/r ) = atan2( Z, sqrt( X*X + Y*Y ) )
>
>(the second formula for "lat = .." has the advantage of being accurate
> also very close to 90 degrees)

I don't want to raise a show-stopper, but what you describe here is a
latitude longitude radius conversion with respect to x y and z. As far
as I know this is NOT the same as azimuth elevation, which define how
an object is positioned with respect to an observer on the earth's
surface. Azimuth is defined as the angle with respect to the local
meridian ( call it your local north ). Elevation is the angle with
respect to your local horizon (elevation=0 is the horizon, elevation=90
is your zenith, elevation -90 is called your nadir). Azimuth=0 is called
north, 90=east, 180=south and 270 is west. What you need to compute
the azimuth and elevation angle are: coordinates of the observer
+ coordinates of the object that is observed, both in a geocentric
system. For your information, below I appended a fortran subroutine
to compute the azimuth and zenith angles given the observer coordinates
(here called station coordinates) and the object coordinates.

>
>The "atan2( Y, X )" is available as a library function in C and Fortran,
>in other languages code it as:
>
>if X > 0 then return atan( Y/X )
>if X < 0 then return atan( Y/X ) +- pi (or 180 degrees)
>if X = 0 and Y > 0 then return pi/2 (or 90 degrees)
>if X = 0 and Y < 0 then return -pi/2 (or -90 degrees)
>
>If both X and Y are exactly zero, the result of atan2(0,0) is really
>undefined -- however it works well to set the result equal to zero in
>such cases (think about it: what's the longitude of the North or South
>Pole on Earth?)
>
>Finally, should the division Y/X cause an arithmetic overflow, treat this
>as if X was exactly zero.
>
>--
>---
>Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
>Nybrogatan 75 A, 6 tr, S-114 40 Stockholm, Sweden
>InterNet: pau...@saaf.se


subroutine azizen(xs0,ys0,zs0,xl0,yl0,zl0,azimuth,zenith)
c
c subroutine azimuthzenith computes the azimuth and the zenith angles
c for the station located in xs0,ys0,zs0 observing the object
c xl0,yl0,zl0. All computations are done on the unit sphere.
c
c made by: esch...@geodesy2.gsfc.nasa.gov
c
implicit none

real*8 xs0,ys0,zs0,xl0,yl0,zl0,azimuth,zenith
real*8 xs,ys,zs,xl,yl,zl,lens,lenl
real*8 fact,inpro,xn,yn,zn,xp,yp,zp,norm,xla,yla
real*8 coslam,sinlam
c
c convert to unit sphere
c
lens = dsqrt( xs0**2 + ys0**2 + zs0**2 )
xs = xs0/lens
ys = ys0/lens
zs = zs0/lens
lenl = dsqrt( xl0**2 + yl0**2 + zl0**2 )
xl = xl0/lenl
yl = yl0/lenl
zl = zl0/lenl
c
c the zenith angle
c
fact = 180d0/(4d0*datan(1d0))
inpro = xs*xl + ys*yl + zs*zl
if (inpro.gt.1d0) inpro=1d0
if (inpro.lt.-1d0) inpro=-1d0
zenith = dacos(inpro)*fact
c
c the azimuth angle is the angle between the meridian plane and
c the plane through the locus and the station
c
c
c xp yp zp is the pole vector of the other plane
c
xp = ys*zl - zs*yl
yp = zs*xl - xs*zl
zp = xs*yl - ys*xl

norm = dsqrt(xp**2+yp**2+zp**2)
if (norm.lt.1d-10) then ! meaning that s falls at e (or -e)
azimuth = 0d0
return
end if

xp = xp/norm
yp = yp/norm
zp = zp/norm
c
c xn,yn,zn is perpendicular to the meridian plane
c
xn = ys
yn = -xs
zn = 0d0
norm = dsqrt(xn**2+yn**2)
if (norm.le.1d-10) then
stop 'please move your location from the pole.'
end if
xn = xn / norm
yn = yn / norm
zn = zn / norm
c
c the angles between the pole vectors are the angle between the planes
c
inpro = xn*xp + yn*yp + zn*zp
if (inpro.gt.1d0) inpro=1d0
if (inpro.lt.-1d0) inpro=-1d0
azimuth = dacos(inpro)*fact
c
c check the quadrants
c
coslam = xs
sinlam = ys
xla = coslam*xl + sinlam*yl
yla =-sinlam*xl + coslam*yl
c
c if ysa is negative the locus is past the observing station
c
if (yla.lt.0d0) azimuth = -azimuth
if (azimuth.lt.0d0) azimuth = azimuth + 360d0
if (azimuth.gt.360d0) azimuth = azimuth - 360d0

end
--
Ernst J.O. Schrama, as usual speaking for himself and not for NASA/GSFC.

Of course there is no cat with two tails and one cat has one tail more than
no cat so that one cat must have at least three tails, or maybe even more.

Stuart Martin

unread,
Nov 15, 1993, 9:00:25 AM11/15/93
to

In article <2c5pbr$1...@clarknet.clark.net>, tst...@clark.net (Tim Stark) says:
>
>All:
>
> I am looking for algortihms that convert data between Azimuth-Elevation
>and X-Y-Z coordination formulas. Does anyone have algorithms or formulas?
>If so, I will appericate that. Thanks! I looked into my graphics books but
>no luck. That is for nagivation or astronomy.

Start by converting the azimuth/elevation/range coordinates into a
local topocentric coordinate system, e.g x to the west, y to the south
and z vertically upwards. You need to introduce the third coordinate,
range, by the way - you cannot go from 2 to 3 coordinates !!. Then rotate
about the terrestrial z axis so that the two x- axes are parallel, and
then about the x-axis to make the y & z axes parallel. Then all you need
to do is translate the origin of your rotated topocentric coordinates to
the terrestrial origin.

This becomes a little more tricky if you want to take into account the
fact that the earth isn't quite spherical, but the principle is the
same.

>
>-- Tim Stark
>
>--
>Timothy Stark Inet: tst...@clark.net
>6130 Edsall Rd. #301 TDD: (703)212-9731 FAX: (703)212-7598
>Alexandria, Va. 22304-5859 Voice: Via VA Relay Center (800)828-1140
>"God bless you! - My friend, Washington DC. - The Most Deaf Population City!"

-----------------------------------------------------------------
Stuart Martin (Logica at ESOC) sma...@esoc.bitnet

European Space Operations Centre
Robert-Bosch-Strasse 5, 64285 Darmstadt, Germany

Hal Mueller

unread,
Nov 17, 1993, 11:58:56 AM11/17/93
to
See Pedro Escobal, _Methods of Orbit Determination_. He has an appendix
of 3 dozen coordinate transformations, which can be combined to give you
just about any POV transform you might need (e.g. given an azimuth/elevation/
range from a vehicle whose position you know in absolute xyz coordinates,
what's the azimuth/elevation from a particular point on Mars?)

Original Edition 1965, Reprint 1976 w/corrections, 1978, 1981, 1983, 1985.
Published by Robert Krieger Publishing Company, Krieger Drive, Malabar, FL.
ISBN 0-88275-319-3.


--
Hal Mueller The floggings will continue
hmue...@diamond.tamu.edu until morale improves.

0 new messages