POV-Ray : Newsgroups : povray.general : Function woes : Re: Function woes Server Time
4 Nov 2024 21:24:58 EST (-0500)
  Re: Function woes  
From: Martin Magnusson
Date: 17 Sep 2003 04:14:21
Message: <3f6817dd$1@news.povray.org>
OK, thanks. Now I have other problems though...

First, I declare a function like this:

#declare Gauss =
function(X1, Z1, S) {
   exp( -1 * ( pow(x-X1, 2) + pow(z-Z1, 2) ) / (2*pow(S, 2)) )
}

Then I'd like to use it in an isosurface, but it gives unexpected 
results. Using the macro below does what I want. I would expect the two 
lines inside the function{} to be equal, but when using the one that is 
commented out here, I just get a flat surface. Can somebody tell me why?

#macro Node( Centre_x, Centre_z, Spread )
isosurface
{
   function {
     //y - Gauss( Centre_x, Centre_z, Spread )
     y - exp( -1 * ( pow(x-Centre_x, 2) + pow(z-Centre_z, 2) ) / 
(2*pow(Spread, 2)) )
   }
   contained_by {
     sphere{ <Centre_x, 0, Centre_z>, Spread*5 }
   }
   pigment{ rgbt < 1, 0, 0, 0.5> }
}
#end

camera
{
   location <3, 8, -10>
   look_at <0, 1, 0>
}

light_source
{
   <10000, 10000, -10000>
   rgb 1
}

Node( 0, 0, 1 )


Post a reply to this message

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