home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 January / pcw-0195.iso / polyray / dat / poly / boys.pi < prev    next >
Text File  |  1994-12-31  |  2KB  |  51 lines

  1. // Boy surface
  2. // Formula by way of: Peter Wang
  3.  
  4. // Set up the camera
  5. viewpoint {
  6.    from <0, 0, -20>
  7.    at   <0, 0, 0>
  8.    up   <0, 1, 0>
  9.    angle 10
  10.    resolution 256, 256
  11.    }
  12.  
  13. // Get various surface finishes
  14. include "colors.inc"
  15.  
  16. // Set up background color & lights
  17. background midnight_blue
  18. light < 10, 3, -20>
  19.  
  20. // Definition of Boy surface as a parametric equation
  21. define Boys_surfx (2/3)*(cos(u)*cos(2*v)+sqrt(2)*sin(u)*cos(v))*cos(u) /
  22.                   (sqrt(2) - sin(2*u)*sin(3*v))
  23. define Boys_surfy (2/3)*(cos(u)*sin(2*v)-sqrt(2)*sin(u)*sin(v))*cos(u) /
  24.                   (sqrt(2)-sin(2*u)*sin(3*v))
  25. define Boys_surfz sqrt(2)*cos(u)^2 / (sqrt(2) - sin(2*u)*sin(2*v))
  26.  
  27. // Definition of the surface as a polynomial
  28. define Boys_surf 64*(1-z)^3*z^3-48*(1-z)^2*z^2*(3*x^2+3*y^2+2*z^2)+
  29.                  12*(1-z)*z*(27*(x^2+y^2)^2-24*z^2*(x^2+y^2)+
  30.                            36*sqrt(2)*y*z*(y^2-3*x^2)+4*z^4)+
  31.                  (9*x^2+9*y^2-2*z^2)*(-81*(x^2+y^2)^2-72*z^2*(x^2+y^2)+
  32.                                       108*sqrt(2)*x*z*(x^2-3*y^2)+4*z^4)
  33.  
  34. // Define the surface in two distinct ways, as a parametric surface and
  35. // as a polynomial surface.  Try rendering it both ways...
  36. if (0 == 1)
  37.    object {
  38.       parametric <Boys_surfx,Boys_surfy,Boys_surfz>
  39.       rotate <-20, 0, 0>
  40.       shiny_red
  41.       uv_bounds -pi/2, pi/2, -pi/2, pi/2
  42.       uv_steps 32, 32
  43.       }
  44. else
  45.    object {
  46.       polynomial Boys_surf
  47.       bounding_box <-3, -3, -3>, <3, 3, 3>
  48.       rotate <-20, 0, 0>
  49.       shiny_red
  50.       }
  51.