home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / MISC / PVDAT.ZIP / HELIX.DAT < prev    next >
Encoding:
Text File  |  1991-09-06  |  3.4 KB  |  156 lines

  1. // Persistence of Vision Raytracer
  2. // Sample quartic file
  3. // by Alexander Enzmann
  4.  
  5. #include "shapes.dat"
  6. #include "colors.dat"
  7. #include "textures.dat"
  8. #include "shapesq.dat"
  9.  
  10. {
  11.    Approximation to the helix z = arctan(y/x).
  12.  
  13.    The helix can be approximated with an algebraic equation (kept to the
  14.    range of a quartic) with the following steps:
  15.  
  16.       tan(z) = y/x   =>  sin(z)/cos(z) = y/x   =>
  17.  
  18.    (1) x sin(z) - y cos(z) = 0
  19.  
  20.    Using the taylor expansions for sin, cos about z = 0,
  21.  
  22.       sin(z) = z - z^3/3! + z^5/5! - ...
  23.       cos(z) = 1 - z^2/2! + z^6/6! - ...
  24.  
  25.    Throwing out the high order terms, the expression (1) can be written as:
  26.  
  27.       x (z - z^3/6) - y (1 + z^2/2) = 0, or
  28.  
  29.   (2) -1/6 x z^3 + x z + 1/2 y z^2 - y = 0
  30.  
  31.   This helix (2) turns 90 degrees in the range 0 <= z <= sqrt(2)/2.  By using
  32.   scale <2 2 2>, the helix defined below turns 90 degrees in the range
  33.   0 <= z <= sqrt(2) = 1.4042.
  34. }
  35.  
  36. #declare Red_Helix =
  37. object Helix
  38.    texture
  39.       { gradient <0 1 0>
  40.         color_map
  41.            [0 1.001 color red 1 green 0 blue 0 color red 0 green 1 blue 0]
  42.         end_color_map }
  43.         color red 1 green 0 blue 0
  44.        { scale <1 1.4142 1> }
  45.        phong 1.0
  46.     end_texture
  47.     bounded_by
  48.        sphere <0 0 0> 2.5 end_sphere
  49.        quadric Cylinder_Z scale <2.0 2.0 2.0> end_quadric
  50.     end_bound
  51. end_object
  52.  
  53. #declare Green_Helix =
  54. object Helix
  55.    texture
  56.       {gradient <0 1 0>
  57.        color_map
  58.           [0 1.001 color red 0 green 1 blue 0 color red 1 green 0 blue 0]
  59.        end_color_map }
  60.        color red 0 green 1 blue 0
  61.        { scale <1 1.4142 1> }
  62.        phong 1.0
  63.     end_texture
  64.     bounded_by
  65.        sphere <0 0 0> 2.5 end_sphere
  66.        quadric Cylinder_Z scale <2.0 2.0 2.0> end_quadric
  67.     end_bound
  68. end_object
  69.  
  70. // Glue a bunch of pieces together to make one long helix. 
  71.  
  72. object Green_Helix
  73.    translate <0 0 -4.2426>
  74.    rotate <0 0 160>
  75.    rotate <-90 0 0>
  76.    translate <0 -2 5>
  77. end_object
  78.  
  79. object Red_Helix
  80.    translate <0 0 -2.8284>
  81.    rotate <0 0 70>
  82.    rotate <-90 0 0>
  83.    translate <0 -2 5>
  84. end_object
  85.  
  86. object Green_Helix
  87.    translate <0 0 -1.4142>
  88.    rotate <0 0 160>
  89.    rotate <-90 0 0>
  90.    translate <0 -2 5>
  91. end_object
  92.  
  93. object Red_Helix
  94.    rotate <0 0 70>
  95.    rotate <-90 0 0>
  96.    translate <0 -2 5>
  97. end_object
  98.  
  99. object Green_Helix
  100.    translate <0 0 1.4142>
  101.    rotate <0 0 160>
  102.    rotate <-90 0 0>
  103.    translate <0 -2 5>
  104. end_object
  105.  
  106. object Red_Helix
  107.    translate <0 0 2.8284>
  108.    rotate <0 0 70>
  109.    rotate <-90 0 0>
  110.    translate <0 -2 5>
  111. end_object
  112.  
  113. object Green_Helix
  114.    translate <0 0 4.2426>
  115.    rotate <0 0 160>
  116.    rotate <-90 0 0>
  117.    translate <0 -2 5>
  118. end_object
  119.  
  120. object Red_Helix
  121.    translate <0 0 5.6569>
  122.    rotate <0 0 70>
  123.    rotate <-90 0 0>
  124.    translate <0 -2 5>
  125. end_object
  126.  
  127. object Green_Helix
  128.    translate <0 0 7.0711>
  129.    rotate <0 0 160>
  130.    rotate <-90 0 0>
  131.    translate <0 -2 5>
  132. end_object
  133.  
  134.  
  135. view_point
  136.    location <0.0  0.0 -10.0>
  137.    direction <0.0 0.0 1.0>
  138.    up        <0.0 1.0 0.0>
  139.    right     <1.333 0.0 0.0>
  140. end_view_point
  141.  
  142. // Toss in a couple of light sources. 
  143. object
  144.    sphere <0 0 0> 1 end_sphere
  145.    translate <200 100 -300>
  146.    light_source
  147.    colour red 1.0 green 1.0 blue 1.0
  148. end_object
  149.  
  150. object
  151.    sphere <0 0 0> 1 end_sphere
  152.    translate <-200 100 -300>
  153.    light_source
  154.    colour red 1.0 green 1.0 blue 1.0
  155. end_object
  156.