Example #1
0
        /// <summary>
        /// Compute the eccentric anomaly 'E'
        /// </summary>
        /// <param name="eccentricity"></param>
        /// <param name="meanAnomaly"></param>
        /// <returns></returns>
        internal static double GetEccentricAnomaly(double eccentricity, DegreeModel meanAnomaly)
        {
            var iteration = 0;
            var maxIterationsiteration = 1000000;
            var tolerance = Math.Pow(10, -10);

            var eccentricAnomalyDegrees = new DegreeModel(DegreeHelper.RadiansToDegrees(eccentricity));

            var result = meanAnomaly.Degrees + (eccentricAnomalyDegrees.Degrees * MathDegrees.Sin(meanAnomaly.Degrees));

            while (iteration < maxIterationsiteration)
            {
                var deltaMeanAnomaly      = meanAnomaly.Degrees - (result - (eccentricAnomalyDegrees.Degrees * MathDegrees.Sin(result)));
                var deltaEccentricAnomaly = deltaMeanAnomaly / (1 - (eccentricity * MathDegrees.Cos(result)));
                result = result + deltaEccentricAnomaly;

                if (Math.Abs(deltaEccentricAnomaly) < tolerance)
                {
                    return(result);
                }

                iteration++;
            }

            return(result);
        }
Example #2
0
        public static LocationModel GetLocation(double centricDistance, DegreeModel ascendingNodeLongitude, DegreeModel perihelionOmega, DegreeModel trueAnomaly, DegreeModel inclination)
        {
            var x = centricDistance * (
                (ascendingNodeLongitude.Cos() * MathDegrees.Cos(perihelionOmega.Degrees + trueAnomaly.Degrees)) -
                (ascendingNodeLongitude.Sin() * inclination.Cos() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees)));

            var y = centricDistance * (
                (ascendingNodeLongitude.Sin() * MathDegrees.Cos(perihelionOmega.Degrees + trueAnomaly.Degrees)) +
                (ascendingNodeLongitude.Cos() * inclination.Cos() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees)));


            var z = centricDistance * (inclination.Sin() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees));

            return(new LocationModel(x, y, z));
        }
        private static double GetHourHorizon(
            this CelestialObjectPositionModel celestialObjectPosition,
            double latitudeDegrees,
            double h0)
        {
            if (h0.EqualsWithinTolerance(0, 6))
            {
                return(DegreeHelper.RadiansToDegrees(
                           Math.Acos(
                               -MathDegrees.Tan(latitudeDegrees) *
                               MathDegrees.Tan(celestialObjectPosition.Declination))));
            }

            return(DegreeHelper.RadiansToDegrees(Math.Acos(
                                                     (MathDegrees.Sin(h0) - (MathDegrees.Sin(latitudeDegrees) * MathDegrees.Sin(celestialObjectPosition.Declination))) /
                                                     (MathDegrees.Cos(latitudeDegrees) * MathDegrees.Cos(celestialObjectPosition.Declination)))));
        }
        internal static SkyPositionModel GetSkyPosition(
            double declination,
            double latitude,
            DateTimeOffset dateTimeOffset,
            double siderealTime)
        {
            var azimuth =
                DegreeHelper.RadiansToDegrees(
                    Math.Atan2(
                        MathDegrees.Sin(siderealTime),
                        (MathDegrees.Cos(siderealTime) * MathDegrees.Sin(latitude)) - (MathDegrees.Tan(declination) * MathDegrees.Cos(latitude))));

            var height =
                DegreeHelper.RadiansToDegrees(
                    Math.Asin(
                        (MathDegrees.Sin(latitude) * MathDegrees.Sin(declination)) +
                        (MathDegrees.Cos(latitude) * MathDegrees.Cos(declination) * MathDegrees.Cos(siderealTime))));

            return(new SkyPositionModel(dateTimeOffset, height, azimuth));
        }
 public static double Cos(this DegreeModel model)
 {
     return(MathDegrees.Cos(model.Degrees));
 }