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 >
Text File  |  1989-07-25  |  768b  |  32 lines

  1.  
  2.  
  3. int place(tk,bk,p,k)
  4. Gpoint *p;
  5. int *tk,*bk,k;
  6. {
  7. double m,v=p[k].x,interp;
  8. int i=*tk,j=*bk;
  9. /*
  10.  *   Get new values for tk and bk   
  11.  */
  12. while (top[i].x <= v && i < topn-1) i++;
  13. while (bottom[j].x <= v && j < bottomn-1) j++;
  14. *tk = (i != 0)?i-1:0; *bk = (j != 0)?j-1:0;
  15. i = *tk; j = *bk;
  16. /*
  17.  *   Test for above.
  18.  */
  19. m = (top[i+1].y - top[i].y)/(top[i+1].x - top[i].x);
  20. interp = m*(v - top[i+1].x) + top[i+1].y;
  21. if (interp < p[k].y) return (1);   /*  Point is above top.  */
  22. /*
  23.  *   Test for below.
  24.  */
  25. m = (bottom[j+1].y - bottom[j].y)/(bottom[j+1].x - bottom[j].x);
  26. interp = m*(v - bottom[j+1].x) + bottom[j+1].y;
  27. if (interp > p[k].y) return (-1);   /* Point is below bottom.  */
  28. return (0);   /*  Point is inside mask   */
  29. }
  30.  
  31.  
  32.