home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / SPLINE.ZIP / SPLINE.INC < prev    next >
Encoding:
Text File  |  1997-03-10  |  2.9 KB  |  76 lines

  1. // ***********************************************************
  2. // SPLINE GENERATOR INCLUDE FILE FOR PERSISTENCE OF VISION 3.x
  3. //    ABSOLUTE POSITION SPLINE GENERATOR
  4. // ***********************************************************
  5. //
  6. // Created by Chris Colefax, February 1997
  7. //
  8. // See "Spline.txt" for more information.
  9. //
  10. // ***********************************************************
  11.  
  12. // CHECK DECLARED VARIABLES AND SET DEFAULT VALUES
  13. // ***********************************************
  14.    #declare _SP_tempver = version
  15.    #ifndef (point1)  #declare point1 = <0, 0, 0>  #end
  16.    #ifndef (point2)  #declare point2 = <0, 0, 0>  #end
  17.    #ifndef (point0)  #declare point0 = point1     #end
  18.    #ifndef (point3)  #declare point3 = point2     #end
  19.  
  20.    #ifndef (spline_clock)     #declare spline_clock = clock  #end
  21.    #ifndef (spline_segments)  #declare spline_segments  = 1  #end
  22.    #ifndef (spline_loop)      #declare spline_loop  = false  #end
  23.    #ifndef (_SP_curseg)       #declare _SP_curseg   = 0      #end
  24.  
  25.    #declare spline_segments = int (spline_segments)
  26.    #if (spline_segments = 0)  #declare spline_segments = 1                      #end
  27.    #if (spline_segments < 0)  #declare spline_segments = abs (spline_segments)  #end
  28.  
  29. // CHECK FOR SPLINE LOOP
  30. // *********************
  31.    #if (spline_loop != false & _SP_curseg = 0)
  32.       #declare _SP_point1      = point1
  33.       #declare _SP_point0      = point0
  34.       #declare spline_segments = spline_segments + 1
  35.    #end
  36.  
  37. // CHECK SPLINE CLOCK VALUE
  38. // ************************
  39.    #declare _SP_clock = spline_clock
  40.    #if (_SP_clock != 1)  #declare _SP_clock = mod (spline_clock, 1)  #end
  41.    #if (_SP_clock < 0)   #declare _SP_clock = _SP_clock + 1          #end
  42.  
  43. // CALCULATE SPLINE POSITION
  44. // *************************
  45.    #if (_SP_clock >= (_SP_curseg / spline_segments) & _SP_clock < ((_SP_curseg + 1) / spline_segments))
  46.       #declare _SP_clock  = mod (_SP_clock * spline_segments, 1)
  47.       #declare spline_pos =
  48.          pow(1 - _SP_clock, 3) *     point1 +
  49.          pow(1 - _SP_clock, 2) * 3 * _SP_clock         * (point1 + point1 - point0) +
  50.          (1 - _SP_clock)       * 3 * pow(_SP_clock, 2) * (point2 + point2 - point3) +
  51.          pow(_SP_clock, 3)     *     point2
  52.    #else
  53.       #if (_SP_clock = 1 & _SP_curseg + 1 = spline_segments)
  54.          #declare spline_pos = point2
  55.       #end
  56.    #end
  57.  
  58. // PREPARE FOR NEXT SEGMENT
  59. // ************************
  60.    #declare point0 = point2 + point2 - point3
  61.    #declare point1 = point2
  62.    #declare point2 = point3
  63.  
  64.    #declare _SP_curseg = _SP_curseg + 1
  65.    #if (_SP_curseg >= spline_segments)  #declare _SP_curseg = 0  #end
  66.  
  67. // CLOSE SPLINE FOR LOOPED SPLINES
  68. // *******************************
  69.    #if (spline_loop != false & _SP_curseg + 1 = spline_segments)
  70.       #declare point2 = _SP_point1
  71.       #declare point3 = point2 + point2 - _SP_point0
  72.       #include "Spline.inc"
  73.    #end
  74.  
  75.    #version _SP_tempver
  76.