GPS-Linked Astronomical Clock "pclock" -2 / 3-
Sample Code for Astronomical Arithmatic
SophiaFramework UNIVERSE allows for complicated formulae to be easily written as is.
* Mathematical formulae in C cannot be entered as is when using only BREW native.
Sample 1: Ecliptic Longtitude of the moon ( AstronomicalMath.cpp )
// Calculates the ecliptic longtitude of the moon // T : Years of Julian Calendar Float64 AstronomicalMath::Moon::CalcEclipticLongitude(Float64 T) const { Float64 Am, lambda_m; Am = 0.0040 * sin(DegreeToRadian(119.5 + 1.33 * T)) + 0.0020 * sin(DegreeToRadian(55.0 + 19.34 * T)) + 0.0006 * sin(DegreeToRadian(71.0 + 0.2 * T)) + 0.0006 * sin(DegreeToRadian(54.0 + 19.3 * T)); lambda_m = 218.3161 + 4812.67881 * T + 6.2887 * sin(DegreeToRadian(134.961 + 4771.9886 * T + Am)) + 1.2740 * sin(DegreeToRadian(100.738 + 4133.3536 * T)) + 0.6583 * sin(DegreeToRadian(235.700 + 8905.3422 * T)) + 0.2136 * sin(DegreeToRadian(269.926 + 9543.9773 * T)) + 0.1856 * sin(DegreeToRadian(177.525 + 359.9905 * T)) + 0.1143 * sin(DegreeToRadian(6.546 + 9664.0404 * T)) + 0.0588 * sin(DegreeToRadian(214.22 + 638.635 * T)) + 0.0572 * sin(DegreeToRadian(103.21 + 3773.363 * T)) + 0.0533 * sin(DegreeToRadian(10.66 + 13677.331 * T)) + 0.0459 * sin(DegreeToRadian(238.18 + 8545.352 * T)) + 0.0410 * sin(DegreeToRadian(137.43 + 4411.998 * T)) + 0.0348 * sin(DegreeToRadian(117.84 + 4452.671 * T)) + 0.0305 * sin(DegreeToRadian(312.49 + 5131.979 * T)) + 0.0153 * sin(DegreeToRadian(130.84 + 758.698 * T)) + 0.0125 * sin(DegreeToRadian(141.51 + 14436.029 * T)) + 0.0110 * sin(DegreeToRadian(231.59 + 4892.052 * T)) + 0.0107 * sin(DegreeToRadian(336.44 + 13038.696 * T)) + 0.0100 * sin(DegreeToRadian(44.89 + 14315.966 * T)) + 0.0085 * sin(DegreeToRadian(201.5 + 8266.71 * T)) + 0.0079 * sin(DegreeToRadian(278.2 + 4493.34 * T)) + 0.0068 * sin(DegreeToRadian(53.2 + 9265.33 * T)) + 0.0052 * sin(DegreeToRadian(197.2 + 319.32 * T)) + 0.0050 * sin(DegreeToRadian(295.4 + 4812.66 * T)) + 0.0048 * sin(DegreeToRadian(235.0 + 19.34 * T)) + 0.0040 * sin(DegreeToRadian(13.2 + 13317.34 * T)) + 0.0040 * sin(DegreeToRadian(145.6 + 18449.32 * T)) + 0.0040 * sin(DegreeToRadian(119.5 + 1.33 * T)) + 0.0039 * sin(DegreeToRadian(111.3 + 17810.68 * T)) + 0.0037 * sin(DegreeToRadian(349.1 + 5410.62 * T)) + 0.0027 * sin(DegreeToRadian(272.5 + 9183.99 * T)) + 0.0026 * sin(DegreeToRadian(107.2 + 13797.39 * T)) + 0.0024 * sin(DegreeToRadian(211.9 + 988.63 * T)) + 0.0024 * sin(DegreeToRadian(252.8 + 9224.66 * T)) + 0.0022 * sin(DegreeToRadian(240.6 + 8185.36 * T)) + 0.0021 * sin(DegreeToRadian(87.5 + 9903.97 * T)) + 0.0021 * sin(DegreeToRadian(175.1 + 719.98 * T)) + 0.0021 * sin(DegreeToRadian(105.6 + 3413.37 * T)) + 0.0020 * sin(DegreeToRadian(55.0 + 19.34 * T)) + 0.0018 * sin(DegreeToRadian(4.1 + 4013.29 * T)) + 0.0016 * sin(DegreeToRadian(242.2 + 18569.38 * T)) + 0.0012 * sin(DegreeToRadian(339.0 + 12678.71 * T)) + 0.0011 * sin(DegreeToRadian(276.5 + 19208.02 * T)) + 0.0009 * sin(DegreeToRadian(218.0 + 8586.0 * T)) + 0.0008 * sin(DegreeToRadian(188.0 + 14037.3 * T)) + 0.0008 * sin(DegreeToRadian(204.0 + 7906.7 * T)) + 0.0007 * sin(DegreeToRadian(140.0 + 4052.0 * T)) + 0.0007 * sin(DegreeToRadian(275.0 + 4853.3 * T)) + 0.0007 * sin(DegreeToRadian(216.0 + 278.6 * T)) + 0.0006 * sin(DegreeToRadian(128.0 + 1118.7 * T)) + 0.0005 * sin(DegreeToRadian(247.0 + 22582.7 * T)) + 0.0005 * sin(DegreeToRadian(181.0 + 19088.0 * T)) + 0.0005 * sin(DegreeToRadian(114.0 + 17450.7 * T)) + 0.0005 * sin(DegreeToRadian(332.0 + 5091.3 * T)) + 0.0004 * sin(DegreeToRadian(313.0 + 398.7 * T)) + 0.0004 * sin(DegreeToRadian(278.0 + 120.1 * T)) + 0.0004 * sin(DegreeToRadian(71.0 + 9584.7 * T)) + 0.0004 * sin(DegreeToRadian(20.0 + 720.0 * T)) + 0.0003 * sin(DegreeToRadian(83.0 + 3814.0 * T)) + 0.0003 * sin(DegreeToRadian(66.0 + 3494.7 * T)) + 0.0003 * sin(DegreeToRadian(147.0 + 18089.3 * T)) + 0.0003 * sin(DegreeToRadian(311.0 + 5492.0 * T)) + 0.0003 * sin(DegreeToRadian(161.0 + 40.7 * T)) + 0.0003 * sin(DegreeToRadian(280.0 + 23221.3 * T)); lambda_m = fmod(lambda_m, 360.0); return (lambda_m >= 0.0) ? lambda_m : (lambda_m + 360.0); }
Sample 2: Ecliptic Latitude of the moon ( AstronomicalMath.cpp )
// Calculates the ecliptic latitude of the moon Float64 AstronomicalMath::Moon::CalcEclipticLatitude(Float64 T) const { Float64 Bm, beta_m; Bm = 0.0267 * sin(DegreeToRadian(234.95 + 19.341 * T)) + 0.0043 * sin(DegreeToRadian(322.1 + 19.36 * T)) + 0.0040 * sin(DegreeToRadian(119.5 + 1.33 * T)) + 0.0026 * sin(DegreeToRadian(55.0 + 19.34 * T)) + 0.0005 * sin(DegreeToRadian(307.0 + 19.4 * T)); beta_m = 5.1282 * sin(DegreeToRadian(93.273 + 4832.0202 * T + Bm)) + 0.2806 * sin(DegreeToRadian(228.235 + 9604.0088 * T)) + 0.2777 * sin(DegreeToRadian(138.311 + 60.0316 * T)) + 0.1732 * sin(DegreeToRadian(142.427 + 4073.3220 * T)) + 0.0554 * sin(DegreeToRadian(194.01 + 8965.374 * T)) + 0.0463 * sin(DegreeToRadian(172.55 + 698.667 * T)) + 0.0326 * sin(DegreeToRadian(328.96 + 13737.362 * T)) + 0.0172 * sin(DegreeToRadian(3.18 + 14375.997 * T)) + 0.0093 * sin(DegreeToRadian(277.4 + 8845.31 * T)) + 0.0088 * sin(DegreeToRadian(176.7 + 4711.96 * T)) + 0.0082 * sin(DegreeToRadian(144.9 + 3713.33 * T)) + 0.0043 * sin(DegreeToRadian(307.6 + 5470.66 * T)) + 0.0042 * sin(DegreeToRadian(103.9 + 18509.35 * T)) + 0.0034 * sin(DegreeToRadian(319.9 + 4433.31 * T)) + 0.0025 * sin(DegreeToRadian(196.5 + 8605.38 * T)) + 0.0022 * sin(DegreeToRadian(331.4 + 13377.37 * T)) + 0.0021 * sin(DegreeToRadian(170.1 + 1058.66 * T)) + 0.0019 * sin(DegreeToRadian(230.7 + 9244.02 * T)) + 0.0018 * sin(DegreeToRadian(243.3 + 8206.68 * T)) + 0.0018 * sin(DegreeToRadian(270.8 + 5192.01 * T)) + 0.0017 * sin(DegreeToRadian(99.8 + 14496.06 * T)) + 0.0016 * sin(DegreeToRadian(135.7 + 420.02 * T)) + 0.0015 * sin(DegreeToRadian(211.1 + 9284.69 * T)) + 0.0015 * sin(DegreeToRadian(45.8 + 9964.00 * T)) + 0.0014 * sin(DegreeToRadian(219.2 + 299.96 * T)) + 0.0013 * sin(DegreeToRadian(95.8 + 4472.03 * T)) + 0.0013 * sin(DegreeToRadian(155.4 + 379.35 * T)) + 0.0012 * sin(DegreeToRadian(38.4 + 4812.68 * T)) + 0.0012 * sin(DegreeToRadian(148.2 + 4851.36 * T)) + 0.0011 * sin(DegreeToRadian(138.3 + 19147.99 * T)) + 0.0010 * sin(DegreeToRadian(18.0 + 12978.66 * T)) + 0.0008 * sin(DegreeToRadian(70.0 + 17870.7 * T)) + 0.0008 * sin(DegreeToRadian(326.0 + 9724.1 * T)) + 0.0007 * sin(DegreeToRadian(294.0 + 13098.7 * T)) + 0.0006 * sin(DegreeToRadian(224.0 + 5590.7 * T)) + 0.0006 * sin(DegreeToRadian(52.0 + 13617.3 * T)) + 0.0005 * sin(DegreeToRadian(280.0 + 8485.3 * T)) + 0.0005 * sin(DegreeToRadian(239.0 + 4193.4 * T)) + 0.0004 * sin(DegreeToRadian(311.0 + 9483.9 * T)) + 0.0004 * sin(DegreeToRadian(238.0 + 23281.3 * T)) + 0.0004 * sin(DegreeToRadian(81.0 + 10242.6 * T)) + 0.0004 * sin(DegreeToRadian(13.0 + 9325.4 * T)) + 0.0004 * sin(DegreeToRadian(147.0 + 14097.4 * T)) + 0.0003 * sin(DegreeToRadian(205.0 + 22642.7 * T)) + 0.0003 * sin(DegreeToRadian(107.0 + 18149.4 * T)) + 0.0003 * sin(DegreeToRadian(146.0 + 3353.3 * T)) + 0.0003 * sin(DegreeToRadian(234.0 + 19268.0 * T)); return beta_m; }
Sample 3: Azimuth Difference of the moon ( AstronomicalMath.cpp )
// Calculates the azimuth difference of the moon // T : Years of Julian Calendar Float64 AstronomicalMath::Moon::CalcParallax(Float64 T) const { Float64 p; p = 0.9507 * sin(DegreeToRadian(90.0)) + 0.0518 * sin(DegreeToRadian(224.98 + 4771.989 * T)) + 0.0095 * sin(DegreeToRadian(190.7 + 4133.35 * T)) + 0.0078 * sin(DegreeToRadian(325.7 + 8905.34 * T)) + 0.0028 * sin(DegreeToRadian(0.0 + 9543.98 * T)) + 0.0009 * sin(DegreeToRadian(100.0 + 13677.3 * T)) + 0.0005 * sin(DegreeToRadian(329.0 + 8545.4 * T)) + 0.0004 * sin(DegreeToRadian(194.0 + 3773.4 * T)) + 0.0003 * sin(DegreeToRadian(227.0 + 4412.0 * T)); return p; }