Next / Previous / Contents / TCC Help System / NM Tech homepage

16. coordRotate(): Rotation of spherical coordinates

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.

sidereal.py
# - - -   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 x siny + cos x cosy cos z. Step 2: Take inverse sine to find xt.

sidereal.py
    #-- 1 --
    xt  =  asin ( sin(x) * sin(y) +
                  cos(x) * cos(y) * cos(z) )

Step 3: Find cos yt = (sin x - sin y sinxt) / (cos y cos xt ). Step 4: Take inverse cos to find yt.

sidereal.py
    #-- 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(z) is posive, we must replace yt by 2π-yt.

sidereal.py
    #-- 3 --
    if  sin(z) > 0.0:
        yt  =  TWO_PI - yt

    #-- 4 --
    return (xt, yt)