POV-Ray : Newsgroups : povray.newusers : Advice for a new user looking for a renderer : Re: Advice for a new user looking for a renderer Server Time
30 Jun 2024 04:27:10 EDT (-0400)
  Re: Advice for a new user looking for a renderer  
From: waggy
Date: 1 Nov 2011 15:10:00
Message: <web.4eb042efcb0d82679726a3c10@news.povray.org>
"TSGM" <nomail@nomail> wrote:
> I've given as an example the function whose height is given by the real part of
> z^(1/3) in the complex plane. However, the trick is that this function is
> multi-valued, and so the complete surface must be 'patched together'. Basically,
> this is something that's easy to do as data but not so much as a function.
>
> My hope is for some of you in the POV-Ray community can play around with the
> data files and show me what POV-Ray is capable of. For example, how easy is it
> to create something that looks -as nice- (or even nicer) than what can be
> accomplished in just a few lines of Matlab?

It will take some tweaking and good texturing to get it to look nice, but I'd
like to demonstrate how POV-Ray is well-suited to visualizing mathematical
surfaces directly.  With a little messing around, I found the following branch
cuts seem match the ones in the illustration.

pow( pow(y,2)+pow(x,2),1/6 )*cos(( atan2(y,x)   )/3)
pow( pow(y,2)+pow(x,2),1/6 )*cos((-atan2(y,x)   )/3)
pow( pow(y,2)+pow(x,2),1/6 )*cos(( atan2(y,x)+pi)/3)
pow( pow(y,2)+pow(x,2),1/6 )*cos((-atan2(y,x)+pi)/3)

With that in mind, the macro isobranch() makes short work of these variations in
the file below.  Note the abs(z+...) construction is used to give the surface a
finite thickness.


#version 3.7;

#local z_min = -pi;
#local z_max =  pi;
#local r     =  1.0;

#macro isobranch(s1,s2)
  isosurface {
    function {
    abs( z+s1*pow( pow(y,2)+pow(x,2),1/6 )
       *cos((s2*atan2(y,x) +pi*(s1>0))/3) )
    }
    threshold 0.005  // Controls the thickness of the surface
    max_gradient 100
    accuracy 0.0001
    contained_by{box{<-r,-r,z_min>,< r, r,z_max>}}
  }
#end

intersection{
  cylinder{<0,0,z_min>*0.9999,<0,0,z_max>*0.9999,r*0.9999}
  union{
    isobranch( 1, 1)
    isobranch( 1,-1)
    isobranch(-1, 1)
    isobranch(-1,-1)
  }//end union
  texture{
    pigment{color rgbt<0.5,0.5,1.0, 0.3>}
    finish{ specular 0.5 phong 0.5}
  }//end texture
}//end intersection

background{color<1,1,1>}

light_source{<-10,-10,10> 1}

camera {
  location <-2,-2,2>
  up z sky z
  right -x*image_width/image_height
  look_at   <0,0,0>
  }


Post a reply to this message

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