home *** CD-ROM | disk | FTP | other *** search
/ Freelog 38 / Freelog038.iso / Graphisme3D / Pov / Dos / povmsdos.exe / POVMSDOS.ZIP / INCLUDE / SHAPESQ.INC < prev    next >
Text File  |  1998-01-18  |  11KB  |  337 lines

  1. #ifdef(ShapesQ_Inc_Temp)
  2. // do nothing
  3. #else
  4. #declare ShapesQ_Inc_Temp = version;
  5.  
  6. #ifdef(View_POV_Include_Stack)
  7. #   debug "including shapesq.inc\n"
  8. #end
  9.  
  10. /*
  11.               Persistence of Vision Raytracer Version 3.1
  12.                       Quartic shapes include file
  13.               Several cubic and quartic shape definitions
  14.                           by Alexander Enzmann
  15.  
  16.  In the following descriptions, multiplication of two terms is
  17.  shown as the two terms next to each other (i.e. x y, rather than
  18.  x*y.  The expression c(n, m) is the binomial coefficient, n!/m!(n-m)!.
  19.  
  20. */
  21.  
  22. /* Bicorn
  23.   This curve looks like the top part of a paraboloid, bounded
  24.   from below by another paraboloid.  The basic equation is:
  25.      y^2 - (x^2 + z^2) y^2 - (x^2 + z^2 + 2 y - 1)^2 = 0.  */
  26. #declare Bicorn =
  27.  quartic
  28.   {< 1,   0,   0,   0,  1,   0,   4,   2,   0, -2,
  29.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  30.      0,   0,   0,   1,  0,   3,   0,   4,   0, -4,
  31.      1,   0,  -2,   0,  1>
  32.   }
  33.  
  34. /* Crossed Trough
  35.   This is a surface with four pieces that sweep up from the x-z plane.
  36.   The equation is: y = x^2 z^2.  */
  37. #declare Crossed_Trough =
  38.  quartic
  39.   {< 0,   0,   0,   0,  0,   0,   0,   4,   0,  0,
  40.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  41.      0,   0,   0,   0,  0,   0,   0,   0,   0, -1,
  42.      0,   0,   0,   0,  0>
  43.   }
  44.  
  45. /* a drop coming out of water? This is a curve formed by using the equation
  46.   y = 1/2 x^2 (x + 1) as the radius of a cylinder having the x-axis as
  47.   its central axis. The final form of the equation is:
  48.      y^2 + z^2 = 0.5 (x^3 + x^2) */
  49. #declare Cubic_Cylinder =
  50.  quartic 
  51.   {< 0,   0,   0,   -0.5, 0,   0,   0,   0,   0, -0.5,
  52.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  53.      0,   0,   0,    0,   0,   1,   0,   0,   0,  0,
  54.      0,   0,   1,    0,   0>
  55.   }
  56.  
  57. /* a cubic saddle. The equation is: z = x^3 - y^3. */
  58. #declare Cubic_Saddle_1 =
  59.  quartic 
  60.   {< 0,   0,   0,    1,   0,   0,   0,   0,   0,  0,
  61.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  62.      0,   0,  -1,    0,   0,   0,   0,   0,   0,  0,
  63.      0,   0,   0,   -1,   0>
  64.   }
  65.  
  66. /* Variant of a devil's curve in 3-space.  This figure has a top and
  67.   bottom part that are very similar to a hyperboloid of one sheet,
  68.   however the central region is pinched in the middle leaving two
  69.   teardrop shaped holes. The equation is:
  70.      x^4 + 2 x^2 z^2 - 0.36 x^2 - y^4 + 0.25 y^2 + z^4 = 0.  */
  71. #declare Devils_Curve =
  72.  quartic 
  73.   {<-1,   0,   0,    0,  0,   0,    0,  -2,   0,  0.36,
  74.      0,   0,   0,    0,  0,   0,    0,   0,   0,  0,
  75.      1,   0,   0,    0,  0,  -0.25, 0,   0,   0,  0,
  76.     -1,   0,   0,    0,  0>
  77.    }
  78.  
  79. /* Folium
  80.   This is a folium rotated about the x-axis.  The formula is:
  81.      2 x^2 - 3 x y^2 - 3 x z^2 + y^2 + z^2 = 0. */
  82. #declare Folium =
  83.  quartic 
  84.   {< 0,   0,   0,    0,  0,   0,   0,   0,   0,  2,
  85.      0,   0,  -3,    0,  0,   0,   0,  -3,   0,  0,
  86.      0,   0,   0,    0,  0,   1,   0,   0,   0,  0,
  87.      0,   0,   1,    0,  0>
  88.   }
  89.  
  90. /* Glob - sort of like basic teardrop shape. The equation is:
  91.    y^2 + z^2 = 0.5 x^5 + 0.5 x^4. */
  92. #declare Glob_5 =
  93.  poly 
  94.   {5,
  95.    <-0.5, 0,   0,  -0.5, 0,   0,   0,   0,   0,  0,
  96.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  97.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  98.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  99.      0,   0,   0,   0,   1,   0,   0,   0,   0,  0,
  100.      0,   0,   0,   1,   0,   0>
  101.   }
  102.  
  103. /* Variant of a lemniscate - the two lobes are much more teardrop-like. */
  104. #declare Twin_Glob =
  105.  poly 
  106.   {6,
  107.    < 4,   0,   0,   0,   0,   0,   0,   0,   0, -4,
  108.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  109.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  110.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  111.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  112.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  113.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  114.      1,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  115.      0,   1,   0,   0>
  116.   }
  117.  
  118. /*  Approximation to the helix z = arctan(y/x).
  119.  
  120.    The helix can be approximated with an algebraic equation (kept to the
  121.    range of a quartic) with the following steps:
  122.  
  123.       tan(z) = y/x   =>  sin(z)/cos(z) = y/x   =>
  124.  
  125.    (1) x sin(z) - y cos(z) = 0
  126.  
  127.    Using the taylor expansions for sin, cos about z = 0,
  128.  
  129.       sin(z) = z - z^3/3! + z^5/5! - ...
  130.       cos(z) = 1 - z^2/2! + z^6/6! - ...
  131.  
  132.    Throwing out the high order terms, the expression (1) can be written as:
  133.  
  134.       x (z - z^3/6) - y (1 + z^2/2) = 0, or
  135.  
  136.   (2) -1/6 x z^3 + x z + 1/2 y z^2 - y = 0
  137.  
  138.   This helix (2) turns 90 degrees in the range 0 <= z <= sqrt(2)/2.  By using
  139.   scale <2 2 2>, the helix defined below turns 90 degrees in the range
  140.   0 <= z <= sqrt(2) = 1.4042.
  141. */
  142. #declare Helix =
  143.  quartic 
  144.   {<  0,   0,   0,    0,  0,   0,   0,      0,   0,  0,
  145.       0,   0,   0,    0,  0,   0,  -0.1666, 0,   1,  0,
  146.       0,   0,   0,    0,  0,   0,   0,      0.5, 0, -1,
  147.       0,   0,   0,    0,  0>
  148.    clipped_by
  149.     {object {Cylinder_Z scale 2}
  150.      plane  { z, 1.4142}
  151.      plane  {-z, 0}
  152.     }
  153.    bounded_by{clipped_by}
  154.   }
  155.  
  156. /* This is an alternate Helix, using clipped_by instead of csg intersection. */
  157. #declare Helix_1 = object {Helix}
  158.  
  159. /* Hyperbolic Torus having major radius sqrt(40), minor radius sqrt(12).
  160.   This figure is generated by sweeping a circle along the arms of a
  161.   hyperbola.  The equation is:
  162.  
  163.      x^4 + 2 x^2 y^2 - 2 x^2 z^2 - 104 x^2 + y^4 - 2 y^2 z^2 +
  164.      56 y^2 + z^4 + 104 z^2 + 784 = 0.
  165.  
  166.   See the description for the torus below. */
  167. #declare Hyperbolic_Torus_40_12 =
  168.  quartic 
  169.   {< 1,   0,   0,    0,     2,   0,   0,  -2,   0, -104,
  170.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  171.      1,   0,   0,   -2,     0,  56,   0,   0,   0,    0,
  172.      1,   0, 104,    0,   784>
  173.   }
  174.  
  175. /* Lemniscate of Gerono
  176.   This figure looks like two teardrops with their pointed ends connected.
  177.   It is formed by rotating the Lemniscate of Gerono about the x-axis.
  178.   The formula is:
  179.      x^4 - x^2 + y^2 + z^2 = 0. */
  180. #declare Lemniscate =
  181.  quartic 
  182.   {< 1,   0,   0,   0,   0,   0,   0,   0,   0, -1,
  183.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  184.      0,   0,   0,   0,   0,   1,   0,   0,   0,  0,
  185.      0,   0,   1,   0,   0>
  186.   }
  187.  
  188. /* This is a figure with a bumpy sheet on one side and something that
  189.   looks like a paraboloid (but with an internal bubble).  The formula
  190.   is:
  191.      (x^2 + y^2 + a c x)^2 - (x^2 + y^2)(c - a x)^2.
  192.  
  193.    -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
  194.    -y^2+z^4-z^2
  195.  
  196. */
  197. #declare Quartic_Loop_1 =
  198.  quartic 
  199.   {<99,   0,   0, -40,  98,   0,   0,  98,   0, -99,
  200.      0,   0, -40,   0,   0,   0,   0, -40,   0,   0,
  201.     -1,   0,   0,  -2,   0,   1,   0,   0,   0,   0,
  202.     -1,   0,   1,   0,   0>
  203.   }
  204.  
  205. /* Monkey Saddle
  206.   This surface has three parts that sweep up and three down.  This gives
  207.   a saddle that has a place for two legs and a tail... The equation is:
  208.  
  209.      z = c (x^3 - 3 x y^2).
  210.  
  211.   The value c gives a vertical scale to the surface - the smaller the
  212.   value of c, the flatter the surface will be (near the origin). */
  213. #declare Monkey_Saddle =
  214.  quartic 
  215.   {< 0,   0,   0,   1,  0,   0,   0,   0,   0,  0,
  216.      0,   0,  -3,   0,  0,   0,   0,   0,   0,  0,
  217.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  218.      0,   0,   0,  -1,  0>
  219.   }
  220.  
  221. /* Parabolic Torus having major radius sqrt(40), minor radius sqrt(12).
  222.   This figure is generated by sweeping a circle along the arms of a
  223.   parabola.  The equation is:
  224.  
  225.      x^4 + 2 x^2 y^2 - 2 x^2 z - 104 x^2 + y^4 - 2 y^2 z +
  226.      56 y^2 + z^2 + 104 z + 784 = 0.
  227.  
  228.   See the description for the torus below. */
  229. #declare Parabolic_Torus_40_12 =
  230.  quartic 
  231.   {< 1,   0,   0,    0,     2,   0,   0,   0,  -2, -104,
  232.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  233.      1,   0,   0,    0,    -2,  56,   0,   0,   0,    0,
  234.      0,   0,   1,  104,   784>
  235.   }
  236.  
  237. /* Piriform
  238.   This figure looks like a hersheys kiss. It is formed by sweeping
  239.   a Piriform about the x-axis.  a basic form of the equation is:
  240.      (x^4 - x^3) + y^2 + z^2 = 0.
  241. */
  242. #declare Piriform =
  243.  quartic 
  244.   {< 4,   0,   0,   -4,  0,   0,   0,   0,   0,  0,
  245.      0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  246.      0,   0,   0,    0,  0,   1,   0,   0,   0,  0,
  247.      0,   0,   1,    0,  0>
  248.   }
  249.  
  250. /* n-Roll Mill
  251.   This curve in the plane looks like several hyperbolas with their
  252.   bumps arranged about the origin.  The general formula is:
  253.  
  254.      x^n - c(n,2) x^(n-2) y^2 + c(n,4) x^(n-4) y^4 - ... = a
  255.  
  256.   When rendering in 3-Space, the resulting figure looks like a
  257.   cylinder with indented sides.
  258. */
  259.  
  260. /* Quartic parabola - a 4th degree polynomial (has two bumps at the bottom)
  261.   that has been swept around the z axis. The equation is:
  262.      0.1 x^4 - x^2 - y^2 - z^2 + 0.9 = 0. */
  263. #declare Quartic_Paraboloid =
  264.  quartic 
  265.   {< 0.1, 0,   0,  0,   0,   0,   0,   0,   0,  -1,
  266.      0,   0,   0,  0,   0,   0,   0,   0,   0,   0,
  267.      0,   0,   0,  0,   0,   0,   0,   0,   0,  -1,
  268.      0,   0,  -1,  0,   0.9>
  269.   }
  270.  
  271. /* Quartic Cylinder - a Space Needle?  */
  272. #declare Quartic_Cylinder =
  273.  quartic 
  274.   {< 0,   0,   0,    0,   1,   0,   0,   0,   0,   0.01,
  275.      0,   0,   0,    0,   0,   0,   0,   0,   0,   0,
  276.      0,   0,   0,    1,   0,   0,   0,   0,   0,   0,
  277.      0,   0,   0.01, 0,  -0.01>
  278.   }
  279.  
  280. /* Steiners quartic surface */
  281. #declare Steiner_Surface =
  282.  quartic 
  283.   {< 0,   0,   0,  0,  1,   0,   0,   1,   0,   0,
  284.      0,   0,   0,  0,  1,   0,   0,   0,   0,   0,
  285.      0,   0,   0,  1,  0,   0,   0,   0,   0,   0,
  286.      0,   0,   0,  0,  0>
  287.   }
  288.  
  289. /* Torus having major radius sqrt(40), minor radius sqrt(12) */
  290. #declare Torus_40_12 =
  291.  quartic 
  292.   {< 1,   0,   0,    0,     2,   0,   0,   2,   0, -104,
  293.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  294.      1,   0,   0,    2,     0,  56,   0,   0,   0,    0,
  295.      1,   0, -104,   0,   784>
  296.   }
  297.  
  298. /* Witch of Agnesi */
  299. #declare Witch_Hat =
  300.  quartic 
  301.   {<  0,   0,   0,   0,   0,   0,   1,   0,   0,   0,
  302.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  303.       0,   0,   0,   0,   0,   0,   0,   1,   0,   0.04,
  304.       0,   0,   0,   0,   0.04>
  305.   }
  306.  
  307. /* very rough approximation to the sin-wave surface z = sin(2 pi x y).
  308.   In order to get an approximation good to 7 decimals at a distance of
  309.   1 from the origin would require a polynomial of degree around 60.  This
  310.   would require around 200k coefficients. For best results, scale by
  311.   something like <1 1 0.2>. */
  312. #declare Sinsurf =
  313.  poly 
  314.   {6,
  315.    <    0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  316.     -1116.226, 0, 0,    0,  0,   0,   0,   0,   0,  0,
  317.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  318.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  319.         0,   0,   0,    0,  0,   0,   0,   0,   0, 18.8496,
  320.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  321.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  322.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  323.         0,   0,  -1,    0>
  324.    }
  325.  
  326. /* Empty quartic equation.  Ready to be filled with numbers...
  327.   quartic
  328.    {< 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  329.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  330.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  331.       0,   0,   0,   0,   0>
  332.    }
  333. */
  334.  
  335. #version ShapesQ_Inc_Temp;
  336. #end
  337.