/// <summary> /// Decodes an LongLat Coordinate from it's cartesean equivalent /// Note: This method should ONLY be used to decode cartesean coordinates /// that were originally generated from an LongLatCoordinate of from values /// interpolated from those originally generated from LongLatCoordinates. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static LatLongCoordinate 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 LatLongCoordinate((alt - LAT_OFFSET), AstroConvert.RangeLatitude(AstroConvert.RadToDeg(az)))); }
public void TestRangeLatitude(double value, double expected) { Assert.AreEqual(expected, AstroConvert.RangeLatitude(value)); }