예제 #1
0
        static int FindEclipticCrossings(Observer observer, AstroTime time)
        {
            int i;
            var hor = new Spherical[NUM_SAMPLES];

            /*
             *  The ecliptic is a celestial circle that describes the mean plane of
             *  the Earth's orbit around the Sun. We use J2000 ecliptic coordinates,
             *  meaning the x-axis is defined to where the plane of the Earth's
             *  equator on January 1, 2000 at noon UTC intersects the ecliptic plane.
             *  The positive x-axis points toward the March equinox.
             *  Calculate a rotation matrix that converts J2000 ecliptic vectors
             *  to horizontal vectors for this observer and time.
             */
            RotationMatrix rot = Astronomy.Rotation_ECL_HOR(time, observer);

            /*
             *  Sample several points around the ecliptic.
             *  Remember the horizontal coordinates for each sample.
             */
            for (i = 0; i < NUM_SAMPLES; ++i)
            {
                if (0 != HorizontalCoords(out hor[i], ECLIPLON(i), time, rot))
                {
                    return(1);   /* failure */
                }
            }
            for (i = 0; i < NUM_SAMPLES; ++i)
            {
                double    a1 = hor[i].lat;
                double    a2 = hor[(i + 1) % NUM_SAMPLES].lat;
                double    e1 = ECLIPLON(i);
                double    e2 = ECLIPLON(i + 1);
                double    ex;
                Spherical hx;
                int       error;

                if (a1 * a2 <= 0.0)
                {
                    /* Looks like a horizon crossing. Is altitude going up with longitude or down? */
                    if (a2 > a1)
                    {
                        /* Search for the ecliptic longitude and azimuth where altitude ascends through zero. */
                        error = Search(out ex, out hx, time, rot, e1, e2);
                    }
                    else
                    {
                        /* Search for the ecliptic longitude and azimuth where altitude descends through zero. */
                        error = Search(out ex, out hx, time, rot, e2, e1);
                    }

                    if (error != 0)
                    {
                        return(error);
                    }

                    string direction;
                    if (hx.lon > 0.0 && hx.lon < 180.0)
                    {
                        direction = "ascends ";     /* azimuth is more toward the east than the west */
                    }
                    else
                    {
                        direction = "descends";     /* azimuth is more toward the west than the east */
                    }
                    Console.WriteLine("Ecliptic longitude {0,9:0.0000} {1} through horizon az {2,9:0.0000}, alt {3,12:0.000e+00}", ex, direction, hx.lon, hx.lat);
                }
            }
            return(0);
        }