This function is used by both Section 15.2, “AltAz.raDec(): Horizon to equatorial
coordinates” and
Section 17.3, “RADec.altAz(): Equatorial to horizon
coordinates”. Refer to those sections
for the relevant formulae.
# - - - c o o r d R o t a t e
def coordRotate ( x, y, z ):
"""Used to convert between equatorial and horizon coordinates.
[ x, y, and z are angles in radians ->
return (xt, yt) where
xt=arcsin(sin(x)*sin(y)+cos(x)*cos(y)*cos(z)) and
yt=arccos((sin(x)-sin(y)*sin(xt))/(cos(y)*cos(xt))) ]
"""
Step 1: Find sin xt
= sin
sinx + cos
y cosx cos y. Step 2: Take
inverse sine to find z.
xt
#-- 1 --
xt = asin ( sin(x) * sin(y) +
cos(x) * cos(y) * cos(z) )
Step 3: Find cos = (sin yt - sin x siny) / (cos xt cos y ). Step 4: Take
inverse cos to find xt.
yt
#-- 2 --
yt = acos ( ( sin(x) - sin(y) * sin(xt) ) /
( cos(y) * cos(xt) ) )
Next we must remove the ambiguity caused by the computation
of inverse cosine. The rule here is that if sin() is posive, we must
replace z by 2π-yt.
yt
#-- 3 --
if sin(z) > 0.0:
yt = TWO_PI - yt
#-- 4 --
return (xt, yt)