Practical Astronomy Algorithms in .NET/C#
Loading...
Searching...
No Matches
PAComet.cs
Go to the documentation of this file.
1using System;
2using PALib.Data;
3using PALib.Helpers;
4
5namespace PALib;
6
10public class PAComet
11{
22 public (double cometRAHour, double cometRAMin, double cometDecDeg, double cometDecMin, double cometDistEarth) PositionOfEllipticalComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
23 {
24 int daylightSaving = isDaylightSaving ? 1 : 0;
25
26 double greenwichDateDay = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
27 int greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
28 int greenwichDateYear = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
29
31
32 double timeSinceEpochYears = (PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) - PAMacros.CivilDateToJulianDate(0.0, 1, greenwichDateYear)) / 365.242191 + greenwichDateYear - cometInfo.epoch_EpochOfPerihelion;
33 double mcDeg = 360 * timeSinceEpochYears / cometInfo.period_PeriodOfOrbit;
34 double mcRad = (mcDeg - 360 * (mcDeg / 360).Floor()).ToRadians();
35 double eccentricity = cometInfo.ecc_EccentricityOfOrbit;
36 double trueAnomalyDeg = PAMacros.Degrees(PAMacros.TrueAnomaly(mcRad, eccentricity));
37 double lcDeg = trueAnomalyDeg + cometInfo.peri_LongitudeOfPerihelion;
38 double rAU = cometInfo.axis_SemiMajorAxisOfOrbit * (1 - eccentricity * eccentricity) / (1 + eccentricity * trueAnomalyDeg.ToRadians().Cosine());
39 double lcNodeRad = (lcDeg - cometInfo.node_LongitudeOfAscendingNode).ToRadians();
40 double psiRad = (lcNodeRad.Sine() * cometInfo.incl_InclinationOfOrbit.ToRadians().Sine()).ASine();
41
42 double y = lcNodeRad.Sine() * cometInfo.incl_InclinationOfOrbit.ToRadians().Cosine();
43 double x = lcNodeRad.Cosine();
44
45 double ldDeg = PAMacros.Degrees(y.AngleTangent2(x)) + cometInfo.node_LongitudeOfAscendingNode;
46 double rdAU = rAU * psiRad.Cosine();
47
48 double earthLongitudeLeDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear) + 180.0;
49 double earthRadiusVectorAU = PAMacros.SunDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
50
51 double leLdRad = (earthLongitudeLeDeg - ldDeg).ToRadians();
52 double aRad = (rdAU < earthRadiusVectorAU) ? (rdAU * leLdRad.Sine()).AngleTangent2(earthRadiusVectorAU - rdAU * leLdRad.Cosine()) : (earthRadiusVectorAU * (-leLdRad).Sine()).AngleTangent2(rdAU - earthRadiusVectorAU * leLdRad.Cosine());
53
54 double cometLongDeg1 = (rdAU < earthRadiusVectorAU) ? 180.0 + earthLongitudeLeDeg + PAMacros.Degrees(aRad) : PAMacros.Degrees(aRad) + ldDeg;
55 double cometLongDeg = cometLongDeg1 - 360 * (cometLongDeg1 / 360).Floor();
56 double cometLatDeg = PAMacros.Degrees((rdAU * psiRad.Tangent() * (cometLongDeg1 - ldDeg).ToRadians().Sine() / (earthRadiusVectorAU * (-leLdRad).Sine())).AngleTangent());
57 double cometRAHours1 = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
58 double cometDecDeg1 = PAMacros.EcDec(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
59 double cometDistanceAU = (Math.Pow(earthRadiusVectorAU, 2) + Math.Pow(rAU, 2) - 2.0 * earthRadiusVectorAU * rAU * (lcDeg - earthLongitudeLeDeg).ToRadians().Cosine() * psiRad.Cosine()).SquareRoot();
60
61 int cometRAHour = PAMacros.DecimalHoursHour(cometRAHours1 + 0.008333);
62 int cometRAMin = PAMacros.DecimalHoursMinute(cometRAHours1 + 0.008333);
63 double cometDecDeg = PAMacros.DecimalDegreesDegrees(cometDecDeg1 + 0.008333);
64 double cometDecMin = PAMacros.DecimalDegreesMinutes(cometDecDeg1 + 0.008333);
65 double cometDistEarth = Math.Round(cometDistanceAU, 2);
66
67 return (cometRAHour, cometRAMin, cometDecDeg, cometDecMin, cometDistEarth);
68 }
69
83 public (double cometRAHour, double cometRAMin, double cometRASec, double cometDecDeg, double cometDecMin, double cometDecSec, double cometDistEarth) PositionOfParabolicComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
84 {
85 int daylightSaving = isDaylightSaving ? 1 : 0;
86
87 double greenwichDateDay = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
88 int greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
89 int greenwichDateYear = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
90
92
93 double perihelionEpochDay = cometInfo.EpochPeriDay;
94 int perihelionEpochMonth = cometInfo.EpochPeriMonth;
95 int perihelionEpochYear = cometInfo.EpochPeriYear;
96 double qAU = cometInfo.PeriDist;
97 double inclinationDeg = cometInfo.Incl;
98 double perihelionDeg = cometInfo.ArgPeri;
99 double nodeDeg = cometInfo.Node;
100
101 (double cometLongDeg, double cometLatDeg, double cometDistAU) cometLongLatDist = PAMacros.PCometLongLatDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, perihelionEpochDay, perihelionEpochMonth, perihelionEpochYear, qAU, inclinationDeg, perihelionDeg, nodeDeg);
102
103 double cometRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
104 double cometDecDeg1 = PAMacros.EcDec(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
105
106 int cometRAHour = PAMacros.DecimalHoursHour(cometRAHours);
107 int cometRAMin = PAMacros.DecimalHoursMinute(cometRAHours);
108 double cometRASec = PAMacros.DecimalHoursSecond(cometRAHours);
109 double cometDecDeg = PAMacros.DecimalDegreesDegrees(cometDecDeg1);
110 double cometDecMin = PAMacros.DecimalDegreesMinutes(cometDecDeg1);
111 double cometDecSec = PAMacros.DecimalDegreesSeconds(cometDecDeg1);
112 double cometDistEarth = Math.Round(cometLongLatDist.cometDistAU, 2);
113
115 }
116}
Information about a comet with an elliptical orbit.
Definition CometData.cs:10
double incl_InclinationOfOrbit
Inclination of the orbit.
Definition CometData.cs:49
double epoch_EpochOfPerihelion
Epoch of the perihelion.
Definition CometData.cs:19
double ecc_EccentricityOfOrbit
Eccentricity of the orbit.
Definition CometData.cs:44
double peri_LongitudeOfPerihelion
Longitude of the perihelion.
Definition CometData.cs:24
double period_PeriodOfOrbit
Period of the orbit.
Definition CometData.cs:34
double node_LongitudeOfAscendingNode
Longitude of the ascending node.
Definition CometData.cs:29
Information about a comet with a parabolic orbit.
Definition CometData.cs:56
double Node
Comet's node.
Definition CometData.cs:85
double Incl
Inclination.
Definition CometData.cs:95
double ArgPeri
Arg perihelion.
Definition CometData.cs:80
int EpochPeriYear
Epoch perihelion year.
Definition CometData.cs:75
int EpochPeriMonth
Epoch perihelion month.
Definition CometData.cs:70
double PeriDist
Distance at the perihelion.
Definition CometData.cs:90
double EpochPeriDay
Epoch perihelion day.
Definition CometData.cs:65
Data manager for comets with elliptical orbits.
Definition CometData.cs:102
static CometDataElliptical GetCometEllipticalInfo(string name)
Get information about a comet with an elliptical orbit.
Definition CometData.cs:265
Data manager for comets with parabolic orbits.
Definition CometData.cs:280
static CometDataParabolic GetCometParabolicInfo(string name)
Get information about a comet with a parabolic orbit.
Definition CometData.cs:302
Comet calculations.
Definition PAComet.cs:11
double cometRAHour
Calculate position of an elliptical comet.
Definition PAComet.cs:22
double double double double double cometDistEarth PositionOfEllipticalComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
Definition PAComet.cs:22
double double double cometDecDeg
Definition PAComet.cs:22
double double double double double double cometDecSec
Definition PAComet.cs:83
double double cometRAMin
Definition PAComet.cs:22
double double double double cometDecDeg
Definition PAComet.cs:83
double double double cometRASec
Definition PAComet.cs:83
double double double double double double double cometDistEarth PositionOfParabolicComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
Definition PAComet.cs:83
double double double double cometDecMin
Definition PAComet.cs:22
Miscellaneous macro functions supporting the other classes.
Definition PAMacros.cs:13
static double LocalCivilTimeGreenwichDay(double lctHours, double lctMinutes, double lctSeconds, int daylightSaving, int zoneCorrection, double localDay, int localMonth, int localYear)
Determine Greenwich Day for Local Time.
Definition PAMacros.cs:323
static double CivilDateToJulianDate(double day, double month, double year)
Convert a Greenwich Date/Civil Date (day,month,year) to Julian Date.
Definition PAMacros.cs:87
static double Degrees(double w)
Convert W to Degrees.
Definition PAMacros.cs:463
static double EcDec(double eld, double elm, double els, double bd, double bm, double bs, double gd, int gm, int gy)
Ecliptic - Declination (degrees)
Definition PAMacros.cs:1551
static double SunDist(double lch, double lcm, double lcs, int ds, int zc, double ld, int lm, int ly)
Calculate Sun's distance from the Earth in astronomical units.
Definition PAMacros.cs:1140
static double DecimalDegreesToDegreeHours(double decimalDegrees)
Convert Decimal Degrees to Degree-Hours.
Definition PAMacros.cs:522
static double double double cometDistAU PCometLongLatDist(double lh, double lm, double ls, int ds, int zc, double dy, int mn, int yr, double td, int tm, int ty, double q, double i, double p, double n)
Definition PAMacros.cs:3233
static double EcRA(double eld, double elm, double els, double bd, double bm, double bs, double gd, int gm, int gy)
Ecliptic - Right Ascension (degrees)
Definition PAMacros.cs:1567
static int DecimalHoursMinute(double decimalHours)
Return the minutes part of a Decimal Hours.
Definition PAMacros.cs:55
static double DecimalHoursSecond(double decimalHours)
Return the seconds part of a Decimal Hours.
Definition PAMacros.cs:71
static double DecimalDegreesSeconds(double decimalDegrees)
Return Seconds part of Decimal Degrees.
Definition PAMacros.cs:506
static int DecimalHoursHour(double decimalHours)
Return the hour part of a Decimal Hours.
Definition PAMacros.cs:39
static double SunLong(double lch, double lcm, double lcs, int ds, int zc, double ld, int lm, int ly)
Calculate Sun's ecliptic longitude.
Definition PAMacros.cs:760
static double DecimalDegreesMinutes(double decimalDegrees)
Return Minutes part of Decimal Degrees.
Definition PAMacros.cs:490
static int LocalCivilTimeGreenwichMonth(double lctHours, double lctMinutes, double lctSeconds, int daylightSaving, int zoneCorrection, double localDay, int localMonth, int localYear)
Determine Greenwich Month for Local Time.
Definition PAMacros.cs:340
static double DecimalDegreesDegrees(double decimalDegrees)
Return Degrees part of Decimal Degrees.
Definition PAMacros.cs:474
static double TrueAnomaly(double am, double ec)
Solve Kepler's equation, and return value of the true anomaly in radians.
Definition PAMacros.cs:822
static int LocalCivilTimeGreenwichYear(double lctHours, double lctMinutes, double lctSeconds, int daylightSaving, int zoneCorrection, double localDay, int localMonth, int localYear)
Determine Greenwich Year for Local Time.
Definition PAMacros.cs:356