home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / graphic / qrt / resize.c < prev    next >
C/C++ Source or Header  |  1989-03-26  |  3KB  |  145 lines

  1.  
  2. /**********************************************************
  3.  
  4.       Routines to resize primitives by mx, my, mz
  5.       (used for user defined primitive types).  The
  6.       routines must also scale the position vector by
  7.       that amount.  The scale factors are passed in as
  8.       a vector (mult).
  9.  
  10.  **********************************************************/
  11.  
  12. #include "qrt.h"
  13.  
  14. /* #define RESIZEDEBUG TRUE */
  15.  
  16.  
  17. /**********************************************************
  18.  
  19.    Resizes sphere.  If !(mult.x==mult.y==mult.z) will resize
  20.    by smallest amount.
  21.  
  22.  **********************************************************/
  23.  
  24. Resize_Sphere(obj,mult)
  25.   OBJ_PTR obj;
  26.   VECT_PTR mult;
  27. {
  28.   float size;
  29.  
  30. # ifdef ROBUST
  31.     if (obj->type!=SPHERE) Error(INTERNAL_ERROR,1401);
  32. # endif
  33.  
  34.   size = MIN(MIN(mult->x,mult->y),mult->z);
  35.  
  36.   VectorMult(&(obj->loc),&(obj->loc),mult);
  37.   obj->vect1.x *= size;
  38.  
  39. # ifdef RESIZEDEBUG
  40.     printf("RESIZESPHERE: newloc = %f %f %f\n",
  41.            obj->loc.x,
  42.            obj->loc.y,
  43.            obj->loc.z);
  44.     printf("   new rad = %f\n",obj->vect1.x);
  45. # endif
  46.  
  47. }
  48.  
  49.  
  50. /**********************************************************
  51.  
  52.                  Resizes Planar object
  53.  
  54.  **********************************************************/
  55.  
  56. Resize_Plane(obj,mult)
  57.   OBJ_PTR obj;
  58.   VECT_PTR mult;
  59. {
  60.   float size;
  61.  
  62. # ifdef ROBUST
  63.     if (!((obj->type != PARALLELOGRAM) ||
  64.           (obj->type != TRIANGLE) ||
  65.           (obj->type != RING)))
  66.        Error(INTERNAL_ERROR,1402);
  67. # endif
  68.  
  69.   size = MIN(MIN(mult->x,mult->y),mult->z);
  70.  
  71.   VectorMult(&(obj->vect1),&(obj->vect1),mult);
  72.   VectorMult(&(obj->vect2),&(obj->vect2),mult);
  73.   VectorMult(&(obj->loc),  &(obj->loc),  mult);
  74.  
  75.   obj->vect3.x *= size;      /* for ring */
  76.   obj->vect3.y *= size;
  77.  
  78. # ifdef RESIZEDEBUG
  79.     printf("RESIZEPLANE: newloc = %f %f %f\n",
  80.            obj->loc.x,
  81.            obj->loc.y,
  82.            obj->loc.z);
  83. # endif
  84.  
  85. }
  86.  
  87.  
  88. /**********************************************************
  89.  
  90.                  Resizes Quadratic object
  91.  
  92.  
  93.    16 Mar 89 - fixed bug where mult was declared as float
  94.                instead of VECT_PTR.
  95.  **********************************************************/
  96.  
  97. Resize_Quadratic(obj,mult)
  98.   OBJ_PTR obj;
  99.   VECT_PTR mult;
  100. {
  101.  
  102. # ifdef ROBUST
  103.     if (obj->type!=QUADRATIC)
  104.        Error(INTERNAL_ERROR,1403);
  105. # endif
  106.  
  107.   VectorMult(&(obj->upper),&(obj->upper),mult);
  108.   VectorMult(&(obj->lower),&(obj->lower),mult);
  109.   VectorMult(&(obj->loc),  &(obj->loc),  mult);
  110.  
  111. # ifdef RESIZEDEBUG
  112.     printf("RESIZEQUAD: newloc = %f %f %f\n",
  113.            obj->loc.x,
  114.            obj->loc.y,
  115.            obj->loc.z);
  116. # endif
  117.  
  118. }
  119.  
  120.  
  121. /**********************************************************
  122.  
  123.     Resizes Bbox - doesn't actually do anything, since
  124.     bbox values are filled after the tree is created.
  125.  
  126.  **********************************************************/
  127.  
  128. Resize_Bbox(obj,mult)
  129.   OBJ_PTR obj;
  130.   VECT_PTR mult;
  131. {
  132.  
  133. # ifdef ROBUST
  134.     if (obj->type!=BBOX)
  135.        Error(INTERNAL_ERROR,1404);
  136. # endif
  137.  
  138. # ifdef RESIZEDEBUG
  139.     printf("RESIZEBBOX:\n");
  140. # endif
  141.  
  142. }
  143.  
  144.  
  145.