Пример #1
0
        private static DateTimeOffset entryDateAround(PlanetId star, Sign destSign, DateTimeOffset around)
        {
            Double         speed         = Planet.AverageSpeedOf(star);
            int            dayAdjustment = 0;
            DateTimeOffset date          = around.UtcDateTime.Date;
            Position       pos           = CurrentEphemeris[date, star];

            int dif = destSign.Order - Sign.SignOf(pos.Longitude).Order;

            dayAdjustment = dif > 0 ? (int)((destSign.Order - Sign.SignOf(pos.Longitude).Order - 1) * 30 / speed)
                : (int)((11 + destSign.Order - Sign.SignOf(pos.Longitude).Order) * 30 / speed);

            do
            {
                date = date.AddDays(dayAdjustment);
                pos  = CurrentEphemeris[date, star];
                dayAdjustment--;
            } while (Sign.SignOf(pos.Longitude) != destSign.Previous);

            if (Sign.SignOf(pos.Longitude) != destSign.Previous)
            {
                throw new Exception();
            }

            do
            {
                date = date.AddDays(1);
                pos  = CurrentEphemeris[date, star];
                if (Sign.SignOf(pos.Longitude) == destSign)
                {
                    return(date);
                }
            } while (true);

            throw new Exception();
        }