home *** CD-ROM | disk | FTP | other *** search
/ ANews 3 / AnewsCD3.iso / atari / GRAPHX / POV / 68030.060 / POV31G30 / POVRAY_3.1G / SCENES / OBJECTS / MATH / HELIX.POV < prev    next >
Text File  |  1999-10-30  |  3KB  |  144 lines

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