Exemplo n.º 1
0
        // Wolfram command
        // plot 23.439291111111 - 0.0130041666667*t - 1.63888888889e-07*t^2 + 5.959274797e-09*t^3 t from -1 to 1
        // where t is fraction of Julian Century passed from J2000
        /// <summary>
        /// Get current axial tilt (epsilon) based on date.
        /// Value of 23.4 degrees is slowly decreasing.
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static decimal GetAxialTilt(DateTime dateTime)
        {
            var julianCenturies = JulianDateCalculator.ToJulianCenturiesJ2000(dateTime);

            return(t0
                   + t1 * julianCenturies
                   + t2 * DecimalMath.Power(julianCenturies, 2)
                   + t3 * DecimalMath.Power(julianCenturies, 3));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns distances between two decimal Vector2 instances
 /// </summary>
 /// <param name="V1"></param>
 /// <param name="V2"></param>
 /// <returns></returns>
 public static decimal Distance(Vector2 <decimal> V1, Vector2 <decimal> V2)
 {
     return(DecimalMath.Sqrt(DecimalMath.Power(V1.X - V2.X, 2) + DecimalMath.Power(V1.Y - V2.Y, 2)));
 }
Exemplo n.º 3
0
        public override Vector3 <decimal> EclipticSun3D(DateTime date)
        {
            var degToRad = DecimalMath.Pi / 180;

            var days = JulianDateCalculator.ToJulianDaysJ2000(date);

            var M    = MeanAnomaly(days);
            var MRad = M * degToRad;
            var e    = Eccentricity(days);

#if DEBUG
            Console.WriteLine($"Days = {days} Mean Anomaly={M} Eccentricity = {e}");
#endif

            var sinM  = DecimalMath.Sin(MRad);
            var sin2M = DecimalMath.Sin(2 * MRad);
            var sin3M = DecimalMath.Sin(3 * MRad);
            var sin4M = DecimalMath.Sin(4 * MRad);
            var sin5M = DecimalMath.Sin(5 * MRad);
            var sin6M = DecimalMath.Sin(6 * MRad);
            var e2    = DecimalMath.Power(e, 2);
            var e3    = DecimalMath.Power(e, 3);
            var e4    = DecimalMath.Power(e, 4);
            var e5    = DecimalMath.Power(e, 5);
            var e6    = DecimalMath.Power(e, 6);

            var eccentricAnomalyRad =
                MRad
                + e * sinM
                + e2 * 0.5m * sin2M
                + e3 * (0.375m * sin3M - 0.125m * sinM)
                + e4 * (-(1m / 6m) * sin2M + (1m / 3m) * sin4M)
                + e5 * (-(27m / 128m) * sin3M + (1m / 192m) * sinM + (125m / 384m) * sin5M)
                + e6 * ((1m / 48m) * sin2M + (27 / 80) * sin6M - (4 / 15) * sin4M);

#if DEBUG
            Console.WriteLine($"Eccentric Anomaly {eccentricAnomalyRad * DecimalMath.RadToDeg}");
#endif

            // Calculate true anomaly
            var A  = SemimajorAxis(days);
            var Xv = A * (DecimalMath.Cos(eccentricAnomalyRad) - e);
            var Yv = A * DecimalMath.Sqrt(1.0m - e * e) * DecimalMath.Sin(eccentricAnomalyRad);

            var v = DecimalMath.Atan2(Yv, Xv);
            var r = DecimalMath.Sqrt(Xv * Xv + Yv * Yv);

            //Calculate Heliocentric coordinates
            var N     = LongAscedingNode(days) * degToRad;
            var cosN  = DecimalMath.Cos(N);
            var sinN  = DecimalMath.Sin(N);
            var i     = Inclination(days) * degToRad;
            var cosi  = DecimalMath.Cos(i);
            var sini  = DecimalMath.Sin(i);
            var w     = Peryhelion(days) * degToRad;
            var cosVW = DecimalMath.Cos(v + w);
            var sinVW = DecimalMath.Sin(v + w);

#if DEBUG
            Console.WriteLine($"LongAscNode : {LongAscedingNode(days)}, Inclination : {Inclination(days)}");
            Console.WriteLine($"Peryhelion: {Peryhelion(days)} true anomaly : {DecimalMath.Atan2(Yv, Xv) * DecimalMath.RadToDeg}");
#endif

            var Xh = r * (cosN * cosVW - sinN * sinVW * cosi);
            var Yh = r * (sinN * cosVW + cosN * sinVW * cosi);
            var Zh = r * (sinVW * sini);

#if DEBUG
            Console.WriteLine($"{Name} heliocentric coordinates {Xh} {Yh} {Zh}");
#endif

            return(new Vector3 <decimal>(Xh, Yh, Zh));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Calculate Euclidean metric for 3D points
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <returns></returns>
 public static decimal Distance(Vector3 <decimal> v1, Vector3 <decimal> v2)
 {
     return(DecimalMath.Sqrt(DecimalMath.Power(v1.X - v2.X, 2) + DecimalMath.Power(v1.Y - v2.Y, 2) + DecimalMath.Power(v1.Z - v2.Z, 2)));
 }