aboutsummaryrefslogtreecommitdiff
path: root/DISTANCE.C
diff options
context:
space:
mode:
Diffstat (limited to 'DISTANCE.C')
-rw-r--r--DISTANCE.C20
1 files changed, 20 insertions, 0 deletions
diff --git a/DISTANCE.C b/DISTANCE.C
new file mode 100644
index 0000000..a79ffe1
--- /dev/null
+++ b/DISTANCE.C
@@ -0,0 +1,20 @@
+/*----------------------------------------------------------------------*/
+/* */
+/* distance.c -- Euclidean Distance */
+/* */
+/*----------------------------------------------------------------------*/
+#include <exec\types.h>
+
+/*----------------------------------------------------------------------*/
+/* returns sqroot(dx*dx + dy*dy); */
+/*----------------------------------------------------------------------*/
+SHORT Distance(dx,dy) SHORT dx,dy; {
+ SHORT v,t,i;
+ long n;
+ n = (long)dx*(long)dx + (long)dy*(long)dy;
+ i = 1024;
+ v = 0;
+ while (i!=0) { t = v+i; if ( ((long)t*(long)t) <= n ) v = t; i >>= 1; }
+ return(v);
+ }
+