public static void TangentToCelestial(double X, double Y, double ra0Deg, double de0Deg, out double raDeg, out double deDeg) { double ra0 = ra0Deg * Math.PI / 180; double de0 = de0Deg * Math.PI / 180; double ra = ra0 + Math.Atan(-X / (Math.Cos(de0) - Y * Math.Sin(de0))); double de = Math.Asin((Math.Sin(de0) + Y * Math.Cos(de0)) / Math.Sqrt(1 + X * X + Y * Y)); deDeg = de * 180 / Math.PI; ra = AngleUtility.Range(ra, 2 * Math.PI); raDeg = ra * 180 / Math.PI; }
internal static List <SearchZone> GetZones(double raDeg, double deDeg, double radiusDeg) { raDeg = AngleUtility.Range(raDeg, 360); List <SearchZone> zones = new List <SearchZone>(); double deFrom = deDeg - radiusDeg / 2.0; double deTo = deDeg + radiusDeg / 2.0;; if (deFrom < -90) { deTo = deDeg + Math.Max(Math.Abs(deFrom + 90), radiusDeg / 2.0); deFrom = -90; } else if (deTo > 90) { deFrom = 90 - Math.Max(Math.Abs(deTo - 90), radiusDeg / 2.0); deTo = 90; } double aspect = Math.Cos(Math.Max(Math.Abs(deFrom), Math.Abs(deTo)) * Math.PI / 180); double raFrom = raDeg - (radiusDeg / (2.0 * aspect)); double raTo = raDeg + (radiusDeg / (2.0 * aspect)); if (raTo - raFrom > 360) { raFrom = 0; raTo = 360; } if (raFrom < 0) { // 2 zones: raFrom..360; 0..raTo raFrom = AngleUtility.Range(raFrom, 360); zones.Add(new SearchZone { RAFrom = raFrom, RATo = 360, DEFrom = deFrom, DETo = deTo }); zones.Add(new SearchZone { RAFrom = 0, RATo = raTo, DEFrom = deFrom, DETo = deTo }); } else if (raTo > 360) { // 2 zones: raFrom..360; 0..raTo raTo = AngleUtility.Range(raTo, 360); zones.Add(new SearchZone { RAFrom = raFrom, RATo = 360, DEFrom = deFrom, DETo = deTo }); zones.Add(new SearchZone { RAFrom = 0, RATo = raTo, DEFrom = deFrom, DETo = deTo }); } else { zones.Add(new SearchZone { RAFrom = raFrom, RATo = raTo, DEFrom = deFrom, DETo = deTo }); } return(zones); }