home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / RTrace 1.0 / source / patch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-17  |  3.0 KB  |  79 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Copyright (c) 1988, 1992 Antonio Costa, INESC-Norte.
  3.  * All rights reserved.
  4.  *
  5.  * This code received contributions from the following people:
  6.  *
  7.  *  Roman Kuchkuda      - basic ray tracer
  8.  *  Mark VandeWettering - MTV ray tracer
  9.  *  Augusto Sousa       - overall, shading model
  10.  *
  11.  * Redistribution and use in source and binary forms are permitted
  12.  * provided that the above copyright notice and this paragraph are
  13.  * duplicated in all such forms and that any documentation,
  14.  * advertising materials, and other materials related to such
  15.  * distribution and use acknowledge that the software was developed
  16.  * by Antonio Costa, at INESC-Norte. The name of the author and
  17.  * INESC-Norte may not be used to endorse or promote products derived
  18.  * from this software without specific prior written permission.
  19.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  21.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  22.  */
  23.  
  24. /**********************************************************************
  25.  *    RAY TRACING - Patch - Version 7.3.2                             *
  26.  *                                                                    *
  27.  *    MADE BY    : Antonio Costa, INESC-Norte, October 1988           *
  28.  *    ADAPTED BY : Antonio Costa, INESC-Norte, June 1989              *
  29.  *    MODIFIED BY: Antonio Costa, INESC-Norte, August 1992            *
  30.  **********************************************************************/
  31.  
  32. /***** Patch *****/
  33. #define BLEND1(t) ((real) ((t) * (t) * (3.0 - 2.0 * (t))))
  34. #define BLEND0(t) (1.0 - BLEND1(t))
  35.  
  36. #define DERIV_BLEND1(t) ((real) (6.0 * (t) * (1.0 - (t))))
  37. #define DERIV_BLEND0(t) (-DERIV_BLEND1(t))
  38.  
  39. #define CUBIC(p, i, t, p0)\
  40. do {\
  41.   (p0).x = (p)->c[3][(i)].x + (t) * ((p)->c[2][(i)].x + (t) *\
  42.            ((p)->c[1][(i)].x + (t) * (p)->c[0][(i)].x));\
  43.   (p0).y = (p)->c[3][(i)].y + (t) * ((p)->c[2][(i)].y + (t) *\
  44.            ((p)->c[1][(i)].y + (t) * (p)->c[0][(i)].y));\
  45.   (p0).z = (p)->c[3][(i)].z + (t) * ((p)->c[2][(i)].z + (t) *\
  46.            ((p)->c[1][(i)].z + (t) * (p)->c[0][(i)].z));\
  47. } while (0)
  48.  
  49. #define DERIV_CUBIC(p, i, t, p0)\
  50. do {\
  51.   (p0).x = (p)->c[2][(i)].x + (t) * ((p)->c[1][(i)].x * 2.0 + (t) *\
  52.            (p)->c[0][(i)].x * 3.0);\
  53.   (p0).y = (p)->c[2][(i)].y + (t) * ((p)->c[1][(i)].y * 2.0 + (t) *\
  54.            (p)->c[0][(i)].y * 3.0);\
  55.   (p0).z = (p)->c[2][(i)].z + (t) * ((p)->c[1][(i)].z * 2.0 + (t) *\
  56.            (p)->c[0][(i)].z * 3.0);\
  57. } while (0)
  58.  
  59. #define MULTIPLY(p0, t, p1)\
  60. do {\
  61.   (p1).x = (p0).x * (t);\
  62.   (p1).y = (p0).y * (t);\
  63.   (p1).z = (p0).z * (t);\
  64. } while (0)
  65.  
  66. #define SUBTRACT(p0, p1, p2, p3)\
  67. do {\
  68.   (p3).x = (p0).x - (p1).x - (p2).x;\
  69.   (p3).y = (p0).y - (p1).y - (p2).y;\
  70.   (p3).z = (p0).z - (p1).z - (p2).z;\
  71. } while (0)
  72.  
  73. /* Prototypes */
  74. void patch_divide(xyz_ptr, xyz_ptr, xyz_ptr, xyz_ptr, real, real, real, int, xyz_ptr, xyz_ptr);
  75.  
  76. boolean patch_damped_nr(real, real, xyz_ptr, xyz_ptr);
  77.  
  78. void subpatch_enclose(xyz_ptr, xyz_ptr, xyz_ptr, xyz_ptr, xyz_ptr, xyz_ptr);
  79.