POV-Ray : Newsgroups : povray.advanced-users : Order-8 Polys, and Beyond : Re: Order-8 Polys, and Beyond Server Time
29 Jul 2024 16:20:33 EDT (-0400)
  Re: Order-8 Polys, and Beyond  
From: Warp
Date: 5 Dec 2001 15:11:50
Message: <3c0e7f86@news.povray.org>
Bryan Elwood <bel### [at] airmailnet> wrote:
: Actually Warp, I printed the Isosurface help topic yesterday so that I could
: begin experimenting.  Currently, I'm just more comfortable talking about
: polynomial surfaces.  But you make it sound like isosurfaces are my answer
: just waiting for me to discover.

  Isosurfaces are incredibly versatile compared to polys. They are easier to
write, easier to read/understand, and often they even render faster than
equivalent polys(!).
  An example:

  A torus written with a poly looks like this:

#declare r1=1;
#declare r2=.5;
poly
{ 4,
  <1,0,0,0,2,
   0,0,2,0,-2*(r1*r1+r2*r2),
   0,0,0,0,0,
   0,0,0,0,0,
   1,0,0,2,0,
   2*(r1*r1-r2*r2),0,0,0,0,
   1,0,-2*(r1*r1+r2*r2),0,pow(r1,4)+pow(r2,4)-2*r1*r1*r2*r2>
}

  Writing the exact same polynomial as an isosurface looks like this:

#declare r1=1;
#declare r2=.5;
isosurface
{ function
  { x^4+2*x^2*y^2+2*x^2*z^2-2*(r1^2+r2^2)*x^2+y^4+2*y^2*z^2+2*(r1^2-r2^2)*y^2+
    z^4-2*(r1^2+r2^2)*z^2+(r1^2-r2^2)^2
  }
  contained_by { box { -<r1+r2, r2, r1+r2>, <r1+r2, r2, r1+r2> } }
  // Set accuracy and max_gradient as needed...
}

  Moreover, there is no need to write it in polynomial form. You can write
it a lot shorter and easier to read (and it will probably render faster as
well):

#declare r1=1;
#declare r2=.5;
isosurface
{ function
  { sqrt( (sqrt(x^2+z^2)-r1)^2 + y^2 ) - r2
  }
  contained_by { box { -<r1+r2, r2, r1+r2>, <r1+r2, r2, r1+r2> } }
  // Set accuracy and max_gradient as needed...
}


-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -



-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.