/// <summary> /// Decodes an AzAlt Coordinate from it's cartesean equivalent /// Note: This method should ONLY be used to decode cartesean coordinates /// that were originally generated from an AzAltCoordinate of from values /// interpolated from those originally generated from AzAltCoordinates. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static AltAzCoordinate FromCartesean(double x, double y) { double az = 0.0; double alt = Math.Sqrt((x * x) + (y * y)); if (x > 0) { az = Math.Atan(y / x); } if (x < 0) { if (y >= 0) { az = Math.Atan(y / x) + Math.PI; } else { az = Math.Atan(y / x) - Math.PI; } } if (x == 0) { if (y > 0) { az = Math.PI / 2.0; } else { az = -1 * (Math.PI / 2.0); } } return(new AltAzCoordinate((alt - ALT_OFFSET), AstroConvert.RangeAzimuth(AstroConvert.RadToDeg(az)))); }
public void TestRange360(double value, double expected) { Assert.AreEqual(expected, AstroConvert.RangeAzimuth(value), 0.00001); }
/// <summary> /// Returns the AltAzimuth coordinate for the equatorial using the values /// currently set in the passed AscomTools instance. /// </summary> /// <param name="transform"></param> /// <returns></returns> public void UpdateAltAzimuth(AscomTools tools, DateTime syncTime) { tools.Transform.JulianDateTT = tools.Util.DateLocalToJulian(syncTime); tools.Transform.SetTopocentric(Equatorial.RightAscension, Equatorial.Declination); AltAzimuth = new AltAzCoordinate(tools.Transform.ElevationTopocentric, AstroConvert.RangeAzimuth(tools.Transform.AzimuthTopocentric)); }