home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gems / gemsii / fastupda.c < prev    next >
Text File  |  1991-09-22  |  914b  |  45 lines

  1.  
  2. /*
  3.  * Author: Filippo Tampieri
  4.  */
  5.  
  6. #define FALSE 0
  7. #define TRUE  1
  8. #define DOT(A,B) (A[0] * B[0] + A[1] * B[1] + A[2] * B[2])
  9.  
  10. /*
  11.     vertexIsBehindPlane returns TRUE if point P is behind the
  12.     plane of normal N and coefficient d, FALSE otherwise.
  13. */
  14. vertexIsBehindPlane(P, N, d)
  15. float P[3], N[3], d;
  16. {
  17.     return(DOT(N, P) + d <= 0. ? TRUE : FALSE);
  18. }
  19.  
  20. /*
  21.     boxIsBehindPlane returns TRUE if the axis-aligned box of
  22.     minimum corner Cmin and maximum corner Cmax is behind the
  23.     plane of normal N and coefficient d, FALSE otherwise.
  24. */
  25. boxIsBehindPlane(Cmin, Cmax, N, d)
  26. float Cmin[3], Cmax[3], N[3], d;
  27. {
  28.     register int i;
  29.     float P[3];
  30.  
  31.     /*
  32.         assign to P the corner further away
  33.         along the direction of normal N
  34.     */
  35.     for(i = 0; i < 3; i++)
  36.         P[i] = N[i] >= 0. ? Cmax[i] : Cmin[i];
  37.  
  38.     /* test P against the input plane */
  39.     return(vertexIsBehindPlane(P, N, d));
  40. }
  41.  
  42.  
  43.  
  44.  
  45.