|
|
Can someone help me,
I am trying to create a round(a,b) function. i.e something to take float a and
round it to b decimal places or round it to the nearest b
I need to be able to use it in an isosurface object as say
isosurface{
function{abs(x-round(x,0))}
}
where round(x,0) rounds to 0 decimal places.
I tried a macro like
#macro round(a,b)
val(str(a,64,b)
#end
pov doesnt handle the promotion properly
is there anyway I can construct a function to achieve the same effect?
Post a reply to this message
|
|
|
|
"Woody" <nomail@nomail> wrote:
> Can someone help me,
>
> I am trying to create a round(a,b) function. i.e something to take float a and
> round it to b decimal places or round it to the nearest b
>
> I need to be able to use it in an isosurface object as say
>
> isosurface{
> function{abs(x-round(x,0))}
> }
>
> where round(x,0) rounds to 0 decimal places.
>
> I tried a macro like
>
> #macro round(a,b)
> val(str(a,64,b)
> #end
>
> pov doesnt handle the promotion properly
>
> is there anyway I can construct a function to achieve the same effect?
#declare Round=function
(a,b){select(a,-1,1)*int(abs(a)*pow(10,b)+0.5)/pow(10,b)}
rounds to the b decimal place (should handle negative numbers properly too).
-tgq
Post a reply to this message
|
|