/// <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)))); }