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

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