/// <summary> /// Conversion of mount axis positions in degrees to Ra and Dec /// </summary> /// <param name="axes"></param> /// <returns></returns> internal static double[] AxesXYToRaDec(double[] axes) { var raDec = new[] { axes[0], axes[1] }; switch (SkySettings.AlignmentMode) { case AlignmentModes.algAltAz: var radec = Coordinate.AltAz2RaDec(SkyServer.Altitude, SkyServer.Azimuth, SkySettings.Latitude, SkyServer.SiderealTime); raDec[0] = Coordinate.Ra2Ha12(radec[0], SkyServer.SiderealTime) * 15.0; // ha in degrees raDec[1] = radec[1]; break; case AlignmentModes.algGermanPolar: case AlignmentModes.algPolar: if (raDec[1] > 90) { raDec[0] += 180.0; raDec[1] = 180 - raDec[1]; raDec = Range.RangeAzAlt(raDec); } raDec[0] = SkyServer.SiderealTime - raDec[0] / 15.0; //southern hemi if (SkyServer.SouthernHemisphere) { raDec[1] = -raDec[1]; } break; default: throw new ArgumentOutOfRangeException(); } raDec = Range.RangeRaDec(raDec); return(raDec); }
/// <summary> /// convert a decimal Alt/Az positions to an axes positions. /// </summary> /// <param name="altAz"></param> /// <returns></returns> internal static double[] AltAzToAxesYX(double[] altAz) { var axes = new[] { altAz[0], altAz[1] }; double lst; switch (SkySettings.AlignmentMode) { case AlignmentModes.algAltAz: break; case AlignmentModes.algGermanPolar: lst = SkyServer.SiderealTime; axes = Coordinate.AltAz2RaDec(axes[0], axes[1], SkySettings.Latitude, lst); axes[0] = Coordinate.Ra2Ha12(axes[0], lst) * 15.0; // ha in degrees if (SkyServer.SouthernHemisphere) { axes[1] = -axes[1]; } axes = Range.RangeAzAlt(axes); if (axes[0] > 180.0 || axes[0] < 0) { // adjust the targets to be through the pole axes[0] += 180; axes[1] = 180 - axes[1]; } break; case AlignmentModes.algPolar: lst = SkyServer.SiderealTime; axes = Coordinate.AltAz2RaDec(axes[0], axes[1], SkySettings.Latitude, lst); axes[0] = Coordinate.Ra2Ha12(axes[0], lst) * 15.0; // ha in degrees if (SkyServer.SouthernHemisphere) { axes[1] = -axes[1]; } axes = Range.RangeAzAlt(axes); break; default: throw new ArgumentOutOfRangeException(); } axes = Range.RangeAxesXY(axes); var monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Server, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"Range:{axes[0]},{axes[1]}" }; MonitorLog.LogToMonitor(monitorItem); return(new[] { axes[1], axes[0] }); }