home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_07_06
/
v7n6045a.txt
< prev
next >
Wrap
Text File
|
1989-07-25
|
768b
|
32 lines
int place(tk,bk,p,k)
Gpoint *p;
int *tk,*bk,k;
{
double m,v=p[k].x,interp;
int i=*tk,j=*bk;
/*
* Get new values for tk and bk
*/
while (top[i].x <= v && i < topn-1) i++;
while (bottom[j].x <= v && j < bottomn-1) j++;
*tk = (i != 0)?i-1:0; *bk = (j != 0)?j-1:0;
i = *tk; j = *bk;
/*
* Test for above.
*/
m = (top[i+1].y - top[i].y)/(top[i+1].x - top[i].x);
interp = m*(v - top[i+1].x) + top[i+1].y;
if (interp < p[k].y) return (1); /* Point is above top. */
/*
* Test for below.
*/
m = (bottom[j+1].y - bottom[j].y)/(bottom[j+1].x - bottom[j].x);
interp = m*(v - bottom[j+1].x) + bottom[j+1].y;
if (interp > p[k].y) return (-1); /* Point is below bottom. */
return (0); /* Point is inside mask */
}