public void GetCoordinates() { double jd = 2448724.5; // geocentrical coordinates CrdsEcliptical ecl = LunarMotion.GetCoordinates(jd); Assert.AreEqual(133.162655, ecl.Lambda, 1e-6); Assert.AreEqual(-3.229126, ecl.Beta, 1e-6); Assert.AreEqual(368409.7, ecl.Distance, 1e-1); // get nutation elements var nutation = Nutation.NutationElements(jd); // apparent geocentrical ecliptical coordinates ecl += Nutation.NutationEffect(nutation.deltaPsi); // true obliquity of the Earth orbit double epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // equatorial geocentrical coordinates CrdsEquatorial eq = ecl.ToEquatorial(epsilon); // Max error in Right Ascention is 0.1" of time double errAlpha = new HMS("0h 0m 00.1s").ToDecimalAngle(); // Max error in Declination is 1" of arc double errDelta = new DMS("0* 0' 01''").ToDecimalAngle(); Assert.AreEqual(new HMS("8h 58m 45.2s").ToDecimalAngle(), eq.Alpha, errAlpha); Assert.AreEqual(new DMS("+13* 46' 06''").ToDecimalAngle(), eq.Delta, errDelta); }
/// <summary> /// Calculates equatorial geocentric coordinates of Pluto for current epoch /// </summary> private CrdsEquatorial Pluto_Equatorial0(SkyContext c) { PrecessionalElements pe = Precession.ElementsFK5(Date.EPOCH_J2000, c.JulianDay); CrdsEquatorial eq2000 = c.Get(Pluto_EclipticalJ2000).ToEquatorial(epsilonJ2000); return(Precession.GetEquatorialCoordinates(eq2000, pe)); }
public void CalculatePlanetApparentPlaceLP() { double jde = 2448976.5; double tau = 0; CrdsEcliptical ecl = null; for (int i = 0; i < 2; i++) { CrdsHeliocentrical hEarth = PlanetPositions.GetPlanetCoordinates(3, jde - tau, highPrecision: false); CrdsHeliocentrical hVenus = PlanetPositions.GetPlanetCoordinates(2, jde - tau, highPrecision: false); var rect = hVenus.ToRectangular(hEarth); ecl = rect.ToEcliptical(); tau = PlanetPositions.LightTimeEffect(ecl.Distance); } // Correction for FK5 system CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl); ecl += corr; ecl += Nutation.NutationEffect(16.749 / 3600.0); CrdsEquatorial eq = ecl.ToEquatorial(23.439669); Assert.AreEqual(new HMS("21h 04m 41.459s"), new HMS(eq.Alpha)); Assert.AreEqual(new DMS("-18* 53' 16.66''"), new DMS(eq.Delta)); }
/// <summary> /// Converts coordinates of telescope from epoch used by hardware to current epoch (used in sky map) /// </summary> /// <returns>Equatorial coordinates in current epoch</returns> private CrdsEquatorial ConvertCoordinatesFromTelescopeEpoch() { double jd = new Date(DateTime.UtcNow).ToJulianEphemerisDay(); CrdsEquatorial eq = new CrdsEquatorial(telescope.RightAscension * 15, telescope.Declination); switch (telescope.EquatorialSystem) { default: case EquatorialCoordinateType.equOther: case EquatorialCoordinateType.equTopocentric: break; case EquatorialCoordinateType.equB1950: eq = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(Date.EPOCH_B1950, jd)); break; case EquatorialCoordinateType.equJ2000: eq = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(Date.EPOCH_J2000, jd)); break; case EquatorialCoordinateType.equJ2050: eq = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(Date.EPOCH_J2050, jd)); break; } return(eq); }
public void Phase_PhaseAngle_Elongation() { CrdsEquatorial eqSun = new CrdsEquatorial(20.6579, 8.6964); CrdsEquatorial eqMoon = new CrdsEquatorial(134.6855, 13.7684); const double epslion = 23.440636; CrdsEcliptical sun = eqSun.ToEcliptical(epslion); sun.Distance = 149971520; CrdsEcliptical moon = eqMoon.ToEcliptical(epslion); moon.Distance = 368410; double psi = BasicEphem.Elongation(sun, moon); Assert.AreEqual(110.79, psi, 1e-2); double phaseAngle = BasicEphem.PhaseAngle(psi, sun.Distance, moon.Distance); Assert.AreEqual(69.08, phaseAngle, 1e-2); double phase = BasicEphem.Phase(phaseAngle); Assert.AreEqual(0.68, phase, 1e-2); }
/// <summary> /// Converts coordinates in current epoch to an epoch used by telescope hardware. /// </summary> /// <param name="eq">Equatorial coordinates in current epoch (used by sky map)</param> /// <returns>Coordinates in epoch used by telescope hardware</returns> private CrdsEquatorial ConvertCoordinatesToTelescopeEpoch(CrdsEquatorial eq) { CrdsEquatorial eqT = new CrdsEquatorial(eq); double jd0 = new Date(DateTime.UtcNow).ToJulianEphemerisDay(); switch (telescope.EquatorialSystem) { default: case EquatorialCoordinateType.equOther: case EquatorialCoordinateType.equTopocentric: break; case EquatorialCoordinateType.equB1950: eqT = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(jd0, Date.EPOCH_B1950)); break; case EquatorialCoordinateType.equJ2000: eqT = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(jd0, Date.EPOCH_J2000)); break; case EquatorialCoordinateType.equJ2050: eqT = Precession.GetEquatorialCoordinates(eq, Precession.ElementsFK5(jd0, Date.EPOCH_J2050)); break; } return(eqT); }
/// <inheritdoc/> public void Sync(CrdsEquatorial eq) { try { lock (locker) { if (telescope != null && telescope.Connected) { UnparkIfPossible(); EnableTrackingIfPossible(); if (telescope.CanSync) { var eqT = ConvertCoordinatesToTelescopeEpoch(eq); telescope.SyncToCoordinates(eqT.Alpha / 15, eqT.Delta); } else { RaiseOnMessageShow("$Ascom.Messages.SyncNotSupported"); } } else { Trace.TraceError("Unable to sync (telescope disconnected)."); } } } catch (Exception ex) { RaiseOnMessageShow("$Ascom.Messages.UnableSync"); Trace.TraceError($"Unable to sync {ex}"); } }
/// <inheritdoc/> public void Slew(CrdsEquatorial eq) { try { lock (locker) { if (telescope != null && telescope.Connected) { UnparkIfPossible(); EnableTrackingIfPossible(); var eqT = ConvertCoordinatesToTelescopeEpoch(eq); // Slew if (telescope.CanSlewAsync) { telescope.SlewToCoordinatesAsync(eqT.Alpha / 15, eqT.Delta); } else { Task.Run(() => telescope.SlewToCoordinates(eqT.Alpha / 15, eqT.Delta)); } } } } catch (Exception ex) { Trace.TraceError($"Unable to slew telescope: {ex}"); RaiseOnMessageShow("$Ascom.Messages.UnableSlew"); } }
public ConjunctedStar(string name, string ra, string dec, float pmAlpha, float pmDelta) { this.name = name; Equatorial0 = new CrdsEquatorial(new HMS(ra), new DMS(dec)); PmAlpha = pmAlpha; PmDelta = pmDelta; }
/// <summary> /// Reads data from catalog file as <see cref="Tycho2Star" /> instance. /// </summary> /// <param name="buffer">Binary buffer with stars data</param> /// <param name="offset">Offset value to read the star record</param> /// <param name="eqCenter">Equatorial coordinates of map center, for J2000.0 epoch</param> /// <param name="angle">Maximal angular separation between map center and star coorinates (both coordinates for J2000.0 epoch)</param> /// <remarks> /// Record format: /// [Tyc1][Tyc2][Tyc3][RA][Dec][PmRA][PmDec][Mag] /// [ 2][ 2][ 1][ 8][ 8][ 4][ 4][ 4] /// </remarks> private Tycho2Star GetStar(SkyContext c, byte[] buffer, int offset, CrdsEquatorial eqCenter, double angle, Func <float, bool> magFilter) { float mag = BitConverter.ToSingle(buffer, offset + 29); if (magFilter(mag)) { // Star coordinates at epoch J2000.0 var eq0 = new CrdsEquatorial( BitConverter.ToDouble(buffer, offset + 5), BitConverter.ToDouble(buffer, offset + 13)); if (Angle.Separation(eq0, eqCenter) <= angle) { return(ReadStar(c, buffer, offset)); } else { return(null); } } else { return(null); } }
public override void Calculate(SkyContext context) { // precessional elements var p = Precession.ElementsFK5(Date.EPOCH_J2000, context.JulianDay); foreach (var ds in DeepSkies) { ds.Equatorial = context.Get(Equatorial, ds); ds.Horizontal = context.Get(Horizontal, ds); if (ds.Outline != null) { foreach (var op in ds.Outline) { CrdsEquatorial eq0 = new CrdsEquatorial(op.Equatorial0); // Equatorial coordinates for the mean equinox and epoch of the target date var eq = Precession.GetEquatorialCoordinates(eq0, p); // Nutation effect var eq1 = Nutation.NutationEffect(eq, context.NutationElements, context.Epsilon); // Aberration effect var eq2 = Aberration.AberrationEffect(eq, context.AberrationElements, context.Epsilon); // Apparent coordinates of the object eq += eq1 + eq2; // Apparent horizontal coordinates op.Horizontal = eq.ToHorizontal(context.GeoLocation, context.SiderealTime); } } } }
public Sky() { // Ecliptic LineEcliptic.FromHorizontal = (h) => { var eq = h.ToEquatorial(GeoLocation, LocalSiderealTime); var ec = eq.ToEcliptical(Epsilon); return(new GridPoint(ec.Lambda, ec.Beta)); }; LineEcliptic.ToHorizontal = (c) => { var ec = new CrdsEcliptical(c.Longitude, c.Latitude); var eq = ec.ToEquatorial(Epsilon); return(eq.ToHorizontal(GeoLocation, LocalSiderealTime)); }; // Horizontal grid GridHorizontal.FromHorizontal = (h) => new GridPoint(h.Azimuth, h.Altitude); GridHorizontal.ToHorizontal = (c) => new CrdsHorizontal(c.Longitude, c.Latitude); // Equatorial grid GridEquatorial.FromHorizontal = (h) => { var eq = h.ToEquatorial(GeoLocation, LocalSiderealTime); return(new GridPoint(eq.Alpha, eq.Delta)); }; GridEquatorial.ToHorizontal = (c) => { var eq = new CrdsEquatorial(c.Longitude, c.Latitude); return(eq.ToHorizontal(GeoLocation, LocalSiderealTime)); }; }
/// <summary> /// Gets equatorial coordinates of a star for current epoch /// </summary> public CrdsEquatorial Equatorial(SkyContext c, ushort hrNumber) { Star star = Stars.ElementAt(hrNumber - 1); PrecessionalElements p = c.Get(GetPrecessionalElements); double years = c.Get(YearsSince2000); // Initial coodinates for J2000 epoch CrdsEquatorial eq0 = new CrdsEquatorial(star.Equatorial0); // Take into account effect of proper motion: // now coordinates are for the mean equinox of J2000.0, // but for epoch of the target date eq0.Alpha += star.PmAlpha * years / 3600.0; eq0.Delta += star.PmDelta * years / 3600.0; // Equatorial coordinates for the mean equinox and epoch of the target date CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, p); // Nutation effect var eq1 = Nutation.NutationEffect(eq, c.NutationElements, c.Epsilon); // Aberration effect var eq2 = Aberration.AberrationEffect(eq, c.AberrationElements, c.Epsilon); // Apparent coordinates of the star eq += eq1 + eq2; return(eq); }
public void GetEquatorialCoordinates() { // Equatorial coordinates of Theta Persei CrdsEquatorial eq0 = new CrdsEquatorial(new HMS(2, 44, 11.986), new DMS(49, 13, 42.48)); // proper motion of Theta Persei, units per year CrdsEquatorial pm = new CrdsEquatorial(new HMS(0, 0, 0.03425), -new DMS(0, 0, 0.0895)); // target date (2018 November 13.19) double jd = Date.JulianDay(new Date(2028, 11, 13.19)); Assert.AreEqual(2462088.69, jd); // years since initial epoch double years = (jd - Date.EPOCH_J2000) / 365.25; // Take into account effect of proper motion: // now coordinates are for the mean equinox of J2000.0, // but for epoch of the target date eq0.Alpha += pm.Alpha * years; eq0.Delta += pm.Delta * years; // precessional elements var p = Precession.ElementsFK5(Date.EPOCH_J2000, jd); // Equatorial coordinates for the mean equinox and epoch of the target date CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, p); // Check final results Assert.AreEqual(new HMS(2, 46, 11.331), new HMS(eq.Alpha)); Assert.AreEqual(new DMS(49, 20, 54.54), new DMS(eq.Delta)); }
public static float Rotate(this IMapContext map, PointF p, CrdsEquatorial eq, double PA) { // Point directed to North celestial pole PointF pNorth = map.Project((eq + new CrdsEquatorial(0, 1)).ToHorizontal(map.GeoLocation, map.SiderealTime)); // Clockwise rotation float inc = LineInclinationY(p, pNorth); if (map.IsInverted) { inc = -90 - inc; } float rotation = (float)(inc - (map.IsMirrored ? -1 : 1) * PA); if (map.IsInverted) { rotation = 90 - rotation; } map.Graphics.TranslateTransform(p.X, p.Y); map.Graphics.RotateTransform(rotation); return(rotation); }
public void GetSolarCoordinatesLP() { double jde = 2448908.5; // get Earth coordinates CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(Planet.Earth, jde, highPrecision: false); Assert.AreEqual(19.907372, crds.L, 1e-6); Assert.AreEqual(-0.644, crds.B * 3600, 1e-3); Assert.AreEqual(0.99760775, crds.R, 1e-8); // transform to ecliptical coordinates of the Sun CrdsEcliptical ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R); // get FK5 system correction CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl); Assert.AreEqual(-0.09033, corr.Lambda * 3600, 1e-5); Assert.AreEqual(-0.023, corr.Beta * 3600, 1e-3); // correct solar coordinates to FK5 system ecl += corr; Assert.AreEqual(199.907347, ecl.Lambda, 1e-6); Assert.AreEqual(0.62, ecl.Beta * 3600, 1e-2); Assert.AreEqual(0.99760775, ecl.Distance, 1e-8); var nutation = Nutation.NutationElements(jde); // True obliquity double epsilon = Date.TrueObliquity(jde, nutation.deltaEpsilon); // accuracy is 0.5" Assert.AreEqual(15.908, nutation.deltaPsi * 3600, 0.5); // accuracyis 0.1" Assert.AreEqual(-0.308, nutation.deltaEpsilon * 3600, 0.1); // accuracy is 0.1" Assert.AreEqual(23.4401443, epsilon, 0.1 / 3600.0); // add nutation effect ecl += Nutation.NutationEffect(nutation.deltaPsi); // calculate aberration effect CrdsEcliptical aberration = Aberration.AberrationEffect(ecl.Distance); Assert.AreEqual(-20.539, aberration.Lambda * 3600.0, 1e-3); // add aberration effect ecl += aberration; // convert ecliptical to equatorial coordinates CrdsEquatorial eq = ecl.ToEquatorial(epsilon); // check apparent equatorial coordinates // assume an accuracy of 0.5'' is sufficient Assert.AreEqual(198.378178, eq.Alpha, 1.0 / 3600 * 0.5); Assert.AreEqual(-7.783871, eq.Delta, 1.0 / 3600 * 0.5); }
public void HorizontalToEquatorial() { // Apparent local horizontal coordinates of Venus var hor = new CrdsHorizontal(68.0337, 15.1249); // Geographical coordinates of US Naval Observatory at Washington, DC var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''")); // Date of observation var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay(); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Apparent sidereal time at Greenwich var theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0)); // Expected apparent equatorial coordinates of Venus var eqExpected = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''")); // Tested value var eqActual = hor.ToEquatorial(geo, theta0); Assert.AreEqual(eqExpected.Alpha, eqActual.Alpha, errorInHMS); Assert.AreEqual(eqExpected.Delta, eqActual.Delta, errorInDMS); }
public void EquatorialToHorizontal() { // Apparent equatorial coordinates of Venus var eq = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''")); // Geographical coordinates of US Naval Observatory at Washington, DC var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''")); // Date of observation var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay(); // Mean sidereal time at Greenwich var theta0 = Date.MeanSiderealTime(jd); Assert.AreEqual(new HMS("8h 34m 57.0896s"), new HMS(theta0)); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Apparent sidereal time at Greenwich theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0)); // Expected local horizontal coordinates of Venus var hor = eq.ToHorizontal(geo, theta0); Assert.AreEqual(15.1249, hor.Altitude, 1e-4); Assert.AreEqual(68.0336, hor.Azimuth, 1e-4); }
/// <summary> /// Gets equatorial coordinates of comet tail end /// </summary> private CrdsEquatorial TailEquatorial(SkyContext ctx, Comet c) { var rBody = ctx.Get(RectangularH, c); var rSun = ctx.Get(SunRectangular); // distance from Sun double r = Math.Sqrt(rBody.X * rBody.X + rBody.Y * rBody.Y + rBody.Z * rBody.Z); double k = (r + ctx.Get(Appearance, c).Tail) / r; double x = rSun.X + k * rBody.X; double y = rSun.Y + k * rBody.Y; double z = rSun.Z + k * rBody.Z; // distance from Earth of tail end double Delta = Math.Sqrt(x * x + y * y + z * z); double alpha = Angle.ToDegrees(Math.Atan2(y, x)); double delta = Angle.ToDegrees(Math.Asin(z / Delta)); // geocentric equatoral for J2000.0 var eq0 = new CrdsEquatorial(alpha, delta); // Precessinal elements to convert between epochs var pe = ctx.Get(GetPrecessionalElements); // Equatorial coordinates for the mean equinox and epoch of the target date // No nutation an aberration corrections here, because we do not need high precision return(Precession.GetEquatorialCoordinates(eq0, pe)); }
private CrdsEquatorial SaturnMoon_Equatorial(SkyContext c, int m) { CrdsEquatorial saturnEq = c.Get(Planet_Equatorial, Planet.SATURN); CrdsRectangular planetocentric = c.Get(SaturnMoon_Rectangular, m); PlanetAppearance appearance = c.Get(Planet_Appearance, Planet.SATURN); double semidiameter = c.Get(Planet_Semidiameter, Planet.SATURN); return(planetocentric.ToEquatorial(saturnEq, appearance.P, semidiameter)); }
public void EquatorialToGalactical() { CrdsEquatorial eq = new CrdsEquatorial(new HMS("17h 48m 59.74s"), new DMS("-14* 43' 08.2''")); CrdsGalactical gal = eq.ToGalactical(); Assert.AreEqual(12.9593, gal.l, 1e-4); Assert.AreEqual(6.0463, gal.b, 1e-4); }
public void PositionAngleOfBrightLimb() { CrdsEquatorial eqMoon = new CrdsEquatorial(new HMS("14h 35m 02s"), new DMS("-12* 45' 46''")); CrdsEquatorial eqSun = new CrdsEquatorial(15.843611 * 15, -20.117778); double pa = LunarEphem.PositionAngleOfBrightLimb(eqSun, eqMoon); Assert.AreEqual(114.6, pa, 0.1); }
public void EquatorialToEcliptical() { CrdsEquatorial eq = new CrdsEquatorial(new HMS("7h 45m 18.946s"), new DMS("+28* 01' 34.26''")); CrdsEcliptical ecl = eq.ToEcliptical(23.4392911); Assert.AreEqual(113.215630, ecl.Lambda, errorInDMS); Assert.AreEqual(6.684170, ecl.Beta, errorInDMS); }
private CrdsEquatorial JupiterMoon_Equatorial(SkyContext c, int m) { CrdsEquatorial jupiterEq = c.Get(Planet_Equatorial, Planet.JUPITER); CrdsRectangular planetocentric = c.Get(JupiterMoon_Rectangular, m); PlanetAppearance appearance = c.Get(Planet_Appearance, Planet.JUPITER); double semidiameter = c.Get(Planet_Semidiameter, Planet.JUPITER); return(planetocentric.ToEquatorial(jupiterEq, appearance.P, semidiameter)); }
/// <summary> /// Gets drawing rotation of image, measured clockwise from /// a point oriented to top of the screen towards North celestial pole point /// </summary> /// <param name="eq">Equatorial coordinates of a central point of a body.</param> /// <returns></returns> public static float GetRotationTowardsNorth(this IMapContext map, CrdsEquatorial eq) { // Coordinates of center of a body (image) to be rotated PointF p = map.Project(eq.ToHorizontal(map.GeoLocation, map.SiderealTime)); // Point directed to North celestial pole PointF pNorth = map.Project((eq + new CrdsEquatorial(0, 1)).ToHorizontal(map.GeoLocation, map.SiderealTime)); // Clockwise rotation return(LineInclinationY(p, pNorth)); }
protected VisibilityDetails Visibility(SkyContext c, T body) { double jd = c.JulianDayMidnight; SkyContext ctx = c.Copy(c.JulianDayMidnight); CrdsEquatorial eq = ctx.Get(EquatorialT, body); CrdsEquatorial eqSun = ctx.Get(SunEquatorial); double minBodyAltitude = ctx.MinBodyAltitudeForVisibilityCalculations ?? 5; double minSunAltitude = ctx.MaxSunAltitudeForVisibilityCalculations ?? -5; return(Algorithms.Visibility.Details(eq, eqSun, ctx.GeoLocation, ctx.SiderealTime, minBodyAltitude, minSunAltitude)); }
public void EclipticalToEquatorial() { CrdsEcliptical ecl = new CrdsEcliptical(113.215630, 6.684170); CrdsEquatorial eq = ecl.ToEquatorial(23.4392911); CrdsEquatorial eqExpected = new CrdsEquatorial(new HMS("7h 45m 18.946s"), new DMS("+28* 01' 34.26''")); Assert.AreEqual(eqExpected.Alpha, eq.Alpha, errorInHMS); Assert.AreEqual(eqExpected.Delta, eq.Delta, errorInDMS); }
public void GalacticalToEquatorial() { CrdsEquatorial eqExpected = new CrdsEquatorial(new HMS("17h 48m 59.74s"), new DMS("-14* 43' 08.2''")); CrdsGalactical gal = new CrdsGalactical(12.9593, 6.0463); CrdsEquatorial eq = gal.ToEquatorial(); Assert.AreEqual(eqExpected.Alpha, eq.Alpha, 1e-4); Assert.AreEqual(eqExpected.Delta, eq.Delta, 1e-4); }
public override void Initialize() { // Ecliptic LineEcliptic.FromHorizontal = (h, ctx) => { var eq = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime); var ec = eq.ToEcliptical(ctx.Epsilon); return(new GridPoint(ec.Lambda, ec.Beta)); }; LineEcliptic.ToHorizontal = (c, ctx) => { var ec = new CrdsEcliptical(c.Longitude, c.Latitude); var eq = ec.ToEquatorial(ctx.Epsilon); return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime)); }; // Galactic equator LineGalactic.FromHorizontal = (h, ctx) => { var eq = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime); var eq1950 = Precession.GetEquatorialCoordinates(eq, peTo1950); var gal = eq1950.ToGalactical(); return(new GridPoint(gal.l, gal.b)); }; LineGalactic.ToHorizontal = (c, ctx) => { var gal = new CrdsGalactical(c.Longitude, c.Latitude); var eq1950 = gal.ToEquatorial(); var eq = Precession.GetEquatorialCoordinates(eq1950, peFrom1950); return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime)); }; // Meridian line LineMeridian.FromHorizontal = (h, ctx) => new GridPoint(0, h.Azimuth - 180); LineMeridian.ToHorizontal = (c, context) => new CrdsHorizontal(0, c.Longitude - 180); // Horizontal grid GridHorizontal.FromHorizontal = (h, ctx) => new GridPoint(h.Azimuth, h.Altitude); GridHorizontal.ToHorizontal = (c, context) => new CrdsHorizontal(c.Longitude, c.Latitude); // Equatorial grid GridEquatorial.FromHorizontal = (h, ctx) => { var eq = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime); return(new GridPoint(eq.Alpha, eq.Delta)); }; GridEquatorial.ToHorizontal = (c, ctx) => { var eq = new CrdsEquatorial(c.Longitude, c.Latitude); return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime)); }; }
private ICollection <AstroEvent> ConjuntionsWithPlanets(AstroEventsContext context) { List <AstroEvent> events = new List <AstroEvent>(); for (int p = 1; p <= 8; p++) { if (p != 3) { SkyContext ctx = new SkyContext(context.From, context.GeoLocation, true); double jd = context.From; while (jd < context.To) { if (context.CancelToken?.IsCancellationRequested == true) { return(new AstroEvent[0]); } ctx.JulianDay = jd; jd = NearestPassWithPlanet(ctx, p); CrdsEquatorial eqMoon = ctx.Get(lunarCalc.Equatorial); CrdsEquatorial eqPlanet = ctx.Get(planetsCalc.Planet_Equatorial, p); double semidiameter = ctx.Get(lunarCalc.Semidiameter) / 3600; double separation = Angle.Separation(eqMoon, eqPlanet); string planetName = Text.Get($"Planet.{p}.GenitiveName"); // occultation if (semidiameter >= separation) { events.Add(new AstroEvent(jd, Text.Get("MoonEvents.ConjWithPlanets.Occults", ("planetName", planetName)), lunarCalc.Moon)); } // conjunction else { var planet = planetsCalc.Planets.ElementAt(p - 1); string moonPhase = Formatters.Phase.Format(ctx.Get(lunarCalc.Phase)); string planetMagnitude = Formatters.Magnitude.Format(ctx.Get(planetsCalc.Planet_Magnitude, p)); string angularDistance = conjunctionSeparationFormatter.Format(separation); string direction = eqMoon.Delta > eqPlanet.Delta ? Text.Get("MoonEvents.ConjWithPlanets.Conj.North") : Text.Get("MoonEvents.ConjWithPlanets.Conj.South"); events.Add(new AstroEvent(jd, Text.Get("MoonEvents.ConjWithPlanets.Conj", ("moonPhase", moonPhase), ("angularDistance", angularDistance), ("direction", direction), ("planetName", planetName), ("planetMagnitude", planetMagnitude)), lunarCalc.Moon, planet)); } jd += LunarEphem.SIDEREAL_PERIOD; } } } return(events); }