aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/calcomp/rptheta4.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/gio/calcomp/rptheta4.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/gio/calcomp/rptheta4.x')
-rw-r--r--sys/gio/calcomp/rptheta4.x37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/gio/calcomp/rptheta4.x b/sys/gio/calcomp/rptheta4.x
new file mode 100644
index 00000000..b2ee42b7
--- /dev/null
+++ b/sys/gio/calcomp/rptheta4.x
@@ -0,0 +1,37 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <math.h>
+
+define PIOVER4 (0.25 * PI)
+define THREEPIOVER4 (0.75 * TWOPI)
+
+# RPTHETA4 -- Polar angle, Real precision, 4 arguments; from p1(x,y) to p2(x,y):
+# angle between line segment p1-p2 and horizontal +x axis centered on p1;
+# returned in radians; single precision (see pdtheta4).
+
+real procedure rptheta4 (p1x, p1y, p2x, p2y)
+
+real p1x,p1y, p2x,p2y # x,y of each point
+real dx, dy, ang
+
+begin
+ dx = p2x - p1x
+ dy = p2y - p1y
+
+ if (dx == 0.0) {
+ if (dy >= 0.0) {
+ ang = HALFPI
+ } else {
+ ang = THREEPIOVER4
+ }
+ } else {
+ ang = atan (dy / dx)
+ if (dx < 0.0) { # 2nd or 3rd quadrant
+ ang = ang + PI
+ } else if (dy < 0.0) { # 4th quadrant
+ ang = ang + TWOPI
+ }
+ }
+
+ return (ang)
+end