aboutsummaryrefslogtreecommitdiff
path: root/DISTANCE.C
blob: a79ffe1d6316815c7426f61ef26f9c540d4efd77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
    }