From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- noao/astutil/asttools/astcoord.x | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 noao/astutil/asttools/astcoord.x (limited to 'noao/astutil/asttools/astcoord.x') diff --git a/noao/astutil/asttools/astcoord.x b/noao/astutil/asttools/astcoord.x new file mode 100644 index 00000000..07a01ee3 --- /dev/null +++ b/noao/astutil/asttools/astcoord.x @@ -0,0 +1,56 @@ +# AST_COORD -- Convert spherical coordinates to new system. +# +# This procedure converts the longitude-latitude coordinates (a1, b1) +# of a point on a sphere into corresponding coordinates (a2, b2) in a +# different coordinate system that is specified by the coordinates of its +# origin (ao, bo). The range of a2 will be from -pi to pi. + +procedure ast_coord (ao, bo, ap, bp, a1, b1, a2, b2) + +double ao, bo # Origin of new coordinates (radians) +double ap, bp # Pole of new coordinates (radians) +double a1, b1 # Coordinates to be converted (radians) +double a2, b2 # Converted coordinates (radians) + +double sao, cao, sbo, cbo, sbp, cbp +double x, y, z, xp, yp, zp, temp + +begin + x = cos (a1) * cos (b1) + y = sin (a1) * cos (b1) + z = sin (b1) + xp = cos (ap) * cos (bp) + yp = sin (ap) * cos (bp) + zp = sin (bp) + + # Rotate the origin about z. + sao = sin (ao) + cao = cos (ao) + sbo = sin (bo) + cbo = cos (bo) + temp = -xp * sao + yp * cao + xp = xp * cao + yp * sao + yp = temp + temp = -x * sao + y * cao + x = x * cao + y * sao + y = temp + + # Rotate the origin about y. + temp = -xp * sbo + zp * cbo + xp = xp * cbo + zp * sbo + zp = temp + temp = -x * sbo + z * cbo + x = x * cbo + z * sbo + z = temp + + # Rotate pole around x. + sbp = zp + cbp = yp + temp = y * cbp + z * sbp + y = y * sbp - z * cbp + z = temp + + # Final angular coordinates. + a2 = atan2 (y, x) + b2 = asin (z) +end -- cgit