home *** CD-ROM | disk | FTP | other *** search
/ Computerspiele Selbermachen / computerspieleselbermachen.iso / pov / shapesq.inc < prev    next >
Text File  |  1993-05-25  |  11KB  |  331 lines

  1. // Persistence Of Vision Raytracer 2.0
  2. // Standard include file.
  3.  
  4. // Quartic shapes include file
  5. //
  6. // Several cubic and quartic shape definitions 
  7. // by Alexander Enzmann 
  8.  
  9. /* In the following descriptions, multiplication of two terms is
  10.   shown as the two terms next to each other (i.e. x y, rather than
  11.   x*y.  The expression c(n, m) is the binomial coefficient, n!/m!(n-m)!. */
  12.  
  13. #declare ShapesQ_Inc_Temp = version
  14.  
  15. #version 2.0
  16.  
  17. /* Bicorn
  18.   This curve looks like the top part of a paraboloid, bounded
  19.   from below by another paraboloid.  The basic equation is:
  20.      y^2 - (x^2 + z^2) y^2 - (x^2 + z^2 + 2 y - 1)^2 = 0.  */
  21. #declare Bicorn =
  22.  quartic
  23.   {< 1,   0,   0,   0,  1,   0,   4,   2,   0, -2,
  24.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  25.      0,   0,   0,   1,  0,   3,   0,   4,   0, -4,
  26.      1,   0,  -2,   0,  1>
  27.   }
  28.  
  29. /* Crossed Trough
  30.   This is a surface with four pieces that sweep up from the x-z plane.
  31.   The equation is: y = x^2 z^2.  */
  32. #declare Crossed_Trough =
  33.  quartic 
  34.   {< 0,   0,   0,   0,  0,   0,   0,   4,   0,  0,
  35.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  36.      0,   0,   0,   0,  0,   0,   0,   0,   0, -1,
  37.      0,   0,   0,   0,  0>
  38.   }
  39.  
  40. /* a drop coming out of water? This is a curve formed by using the equation
  41.   y = 1/2 x^2 (x + 1) as the radius of a cylinder having the x-axis as
  42.   its central axis. The final form of the equation is:
  43.      y^2 + z^2 = 0.5 (x^3 + x^2) */
  44. #declare Cubic_Cylinder =
  45.  quartic 
  46.   {< 0,   0,   0,   -0.5, 0,   0,   0,   0,   0, -0.5,
  47.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  48.      0,   0,   0,    0,   0,   1,   0,   0,   0,  0,
  49.      0,   0,   1,    0,   0>
  50.   }
  51.  
  52. /* a cubic saddle. The equation is: z = x^3 - y^3. */
  53. #declare Cubic_Saddle_1 =
  54.  quartic 
  55.   {< 0,   0,   0,    1,   0,   0,   0,   0,   0,  0,
  56.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  57.      0,   0,  -1,    0,   0,   0,   0,   0,   0,  0,
  58.      0,   0,   0,   -1,   0>
  59.   }
  60.  
  61. /* Variant of a devil's curve in 3-space.  This figure has a top and
  62.   bottom part that are very similar to a hyperboloid of one sheet,
  63.   however the central region is pinched in the middle leaving two
  64.   teardrop shaped holes. The equation is:
  65.      x^4 + 2 x^2 z^2 - 0.36 x^2 - y^4 + 0.25 y^2 + z^4 = 0.  */
  66. #declare Devils_Curve =
  67.  quartic 
  68.   {<-1,   0,   0,    0,  0,   0,    0,  -2,   0,  0.36,
  69.      0,   0,   0,    0,  0,   0,    0,   0,   0,  0,
  70.      1,   0,   0,    0,  0,  -0.25, 0,   0,   0,  0,
  71.     -1,   0,   0,    0,  0>
  72.    }
  73.  
  74. /* Folium
  75.   This is a folium rotated about the x-axis.  The formula is:
  76.      2 x^2 - 3 x y^2 - 3 x z^2 + y^2 + z^2 = 0. */
  77. #declare Folium =
  78.  quartic 
  79.   {< 0,   0,   0,    0,  0,   0,   0,   0,   0,  2,
  80.      0,   0,  -3,    0,  0,   0,   0,  -3,   0,  0,
  81.      0,   0,   0,    0,  0,   1,   0,   0,   0,  0,
  82.      0,   0,   1,    0,  0>
  83.   }
  84.  
  85. /* Glob - sort of like basic teardrop shape. The equation is:
  86.    y^2 + z^2 = 0.5 x^5 + 0.5 x^4. */
  87. #declare Glob_5 =
  88.  poly 
  89.   {5,
  90.    <-0.5, 0,   0,  -0.5, 0,   0,   0,   0,   0,  0,
  91.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  92.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  93.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  94.      0,   0,   0,   0,   1,   0,   0,   0,   0,  0,
  95.      0,   0,   0,   1,   0,   0>
  96.   }
  97.  
  98. /* Variant of a lemniscate - the two lobes are much more teardrop-like. */
  99. #declare Twin_Glob =
  100.  poly 
  101.   {6,
  102.    < 4,   0,   0,   0,   0,   0,   0,   0,   0, -4,
  103.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  104.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  105.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  106.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  107.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  108.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  109.      1,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  110.      0,   1,   0,   0>
  111.   }
  112.  
  113. /*  Approximation to the helix z = arctan(y/x).
  114.  
  115.    The helix can be approximated with an algebraic equation (kept to the
  116.    range of a quartic) with the following steps:
  117.  
  118.       tan(z) = y/x   =>  sin(z)/cos(z) = y/x   =>
  119.  
  120.    (1) x sin(z) - y cos(z) = 0
  121.  
  122.    Using the taylor expansions for sin, cos about z = 0,
  123.  
  124.       sin(z) = z - z^3/3! + z^5/5! - ...
  125.       cos(z) = 1 - z^2/2! + z^6/6! - ...
  126.  
  127.    Throwing out the high order terms, the expression (1) can be written as:
  128.  
  129.       x (z - z^3/6) - y (1 + z^2/2) = 0, or
  130.  
  131.   (2) -1/6 x z^3 + x z + 1/2 y z^2 - y = 0
  132.  
  133.   This helix (2) turns 90 degrees in the range 0 <= z <= sqrt(2)/2.  By using
  134.   scale <2 2 2>, the helix defined below turns 90 degrees in the range
  135.   0 <= z <= sqrt(2) = 1.4042.
  136. */
  137. #declare Helix =
  138.  quartic 
  139.   {<  0,   0,   0,    0,  0,   0,   0,      0,   0,  0,
  140.       0,   0,   0,    0,  0,   0,  -0.1666, 0,   1,  0,
  141.       0,   0,   0,    0,  0,   0,   0,      0.5, 0, -1,
  142.       0,   0,   0,    0,  0>
  143.    clipped_by
  144.     {object {Cylinder_Z scale 2}
  145.      plane  { z, 1.4142}
  146.      plane  {-z, 0}
  147.     }
  148.    bounded_by{clipped_by}
  149.   }
  150.  
  151. /* This is an alternate Helix, using clipped_by instead of csg intersection. */
  152. #declare Helix_1 = object {Helix}
  153.  
  154. /* Hyperbolic Torus having major radius sqrt(40), minor radius sqrt(12).
  155.   This figure is generated by sweeping a circle along the arms of a
  156.   hyperbola.  The equation is:
  157.  
  158.      x^4 + 2 x^2 y^2 - 2 x^2 z^2 - 104 x^2 + y^4 - 2 y^2 z^2 +
  159.      56 y^2 + z^4 + 104 z^2 + 784 = 0.
  160.  
  161.   See the description for the torus below. */
  162. #declare Hyperbolic_Torus_40_12 =
  163.  quartic 
  164.   {< 1,   0,   0,    0,     2,   0,   0,  -2,   0, -104,
  165.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  166.      1,   0,   0,   -2,     0,  56,   0,   0,   0,    0,
  167.      1,   0, 104,    0,   784>
  168.   }
  169.  
  170. /* Lemniscate of Gerono
  171.   This figure looks like two teardrops with their pointed ends connected.
  172.   It is formed by rotating the Lemniscate of Gerono about the x-axis.
  173.   The formula is:
  174.      x^4 - x^2 + y^2 + z^2 = 0. */
  175. #declare Lemniscate =
  176.  quartic 
  177.   {< 1,   0,   0,   0,   0,   0,   0,   0,   0, -1,
  178.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  179.      0,   0,   0,   0,   0,   1,   0,   0,   0,  0,
  180.      0,   0,   1,   0,   0>
  181.   }
  182.  
  183. /* This is a figure with a bumpy sheet on one side and something that
  184.   looks like a paraboloid (but with an internal bubble).  The formula
  185.   is:
  186.      (x^2 + y^2 + a c x)^2 - (x^2 + y^2)(c - a x)^2.
  187.  
  188.    -99*x^4+40*x^3-98*x^2*y^2-98*x^2*z^2+99*x^2+40*x*y^2+40*x*z^2+y^4+2*y^2*z^2
  189.    -y^2+z^4-z^2
  190.  
  191. */
  192. #declare Quartic_Loop_1 =
  193.  quartic 
  194.   {<99,   0,   0, -40,  98,   0,   0,  98,   0, -99,
  195.      0,   0, -40,   0,   0,   0,   0, -40,   0,   0,
  196.     -1,   0,   0,  -2,   0,   1,   0,   0,   0,   0,
  197.     -1,   0,   1,   0,   0>
  198.   }
  199.  
  200. /* Monkey Saddle
  201.   This surface has three parts that sweep up and three down.  This gives
  202.   a saddle that has a place for two legs and a tail... The equation is:
  203.  
  204.      z = c (x^3 - 3 x y^2).
  205.  
  206.   The value c gives a vertical scale to the surface - the smaller the
  207.   value of c, the flatter the surface will be (near the origin). */
  208. #declare Monkey_Saddle =
  209.  quartic 
  210.   {< 0,   0,   0,   1,  0,   0,   0,   0,   0,  0,
  211.      0,   0,  -3,   0,  0,   0,   0,   0,   0,  0,
  212.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  213.      0,   0,   0,  -1,  0>
  214.   }
  215.  
  216. /* Parabolic Torus having major radius sqrt(40), minor radius sqrt(12).
  217.   This figure is generated by sweeping a circle along the arms of a
  218.   parabola.  The equation is:
  219.  
  220.      x^4 + 2 x^2 y^2 - 2 x^2 z - 104 x^2 + y^4 - 2 y^2 z +
  221.      56 y^2 + z^2 + 104 z + 784 = 0.
  222.  
  223.   See the description for the torus below. */
  224. #declare Parabolic_Torus_40_12 =
  225.  quartic 
  226.   {< 1,   0,   0,    0,     2,   0,   0,   0,  -2, -104,
  227.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  228.      1,   0,   0,    0,    -2,  56,   0,   0,   0,    0,
  229.      0,   0,   1,  104,   784>
  230.   }
  231.  
  232. /* Piriform
  233.   This figure looks like a hersheys kiss. It is formed by sweeping
  234.   a Piriform about the x-axis.  a basic form of the equation is:
  235.      (x^4 - x^3) + y^2 + z^2 = 0.
  236. */
  237. #declare Piriform =
  238.  quartic 
  239.   {< 4,   0,   0,   -4,  0,   0,   0,   0,   0,  0,
  240.      0,   0,   0,    0,