Guest User

Untitled

a guest
Sep 16th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer min(integer A, integer B)
  2. {
  3.     if (A<B)
  4.         return A;
  5.     else
  6.         return B;
  7.  
  8. }
  9.  
  10. integer max(integer A, integer B)
  11. {
  12.     if (A>B)
  13.         return A;
  14.     else
  15.         return B;
  16.  
  17. }
  18. //determines if a xyz location is inside the cube formed by the two opposite corners
  19. integer InCube(vector where, vector c1, vector c2)
  20. {
  21.     integer xmin; integer xmax;
  22.     integer ymin; integer ymax;
  23.     integer zmin; integer zmax;
  24.  
  25.     xmin=min((integer)c1.x, (integer)c2.x);
  26.     xmax=max((integer)c1.x, (integer)c2.x);
  27.  
  28.     ymin=min((integer)c1.y, (integer)c2.y);
  29.     ymax=max((integer)c1.y, (integer)c2.y);
  30.  
  31.     zmin=min((integer)c1.z, (integer)c2.z);
  32.     zmax=max((integer)c1.z, (integer)c2.z);
  33.  
  34.     if ((where.x>=xmin) && (where.x<=xmax))
  35.     {
  36.         if ((where.y>=ymin) && (where.y<=ymax))
  37.         {
  38.             if ((where.z>=zmin) && (where.z<=zmax))
  39.             {
  40.                 return TRUE;
  41.             }
  42.         }
  43.     }
  44.     return FALSE;
  45. }
Add Comment
Please, Sign In to add comment