POV-Ray : Newsgroups : povray.unofficial.patches : Isosurface & float functions : Re: Isosurface & float functions Server Time
2 Sep 2024 20:16:00 EDT (-0400)
  Re: Isosurface & float functions  
From: Lummox JR
Date: 22 Jul 1999 14:53:34
Message: <379768E3.4CB2@aol.com>
Gilles Tran wrote:
> 
> This is something I've noticed a while ago but didn't care about until
> recently : some math functions are not recognized in the isosurface
> function declaration : pow, log, atan2, int, ceil, floor.
> function  y + sqrt(x) works
> but
> function  y + pow(x,0.5) returns an error ("float factor expected but
> pow found instead")
> 
> Any clue about this behavior ? Or am I missing something obvious ? It
> looks like the part of the patch that parses the function declaration
> doesn't know about these particular float functions.

pow() is supported by the ^ operator, as TonyB pointed out, so y+x^0.5
will work for you, but sqrt() is still the better way to go for its
simplicity. The function is cleaner and faster. log() doesn't work but
ln() does, so if you want a base-10 log you can always use ln(x)/ln(10).
As for atan2(), floor(), and ceil(), I added them myself, a few weeks
ago. I also added pi and clock, so you can use them directly, without
having to #declare a variable to sub in for them first. And, I added
radians() and degrees(), and if()--which is a binary function that works
like this:

if(condition,expr1,expr2)

If condition>0, return expr1
Else return expr2

I've found if() is handy for a means of bounding density functions, as I
originally intended ceil() and floor() to be.
It's actually not hard to add functions to the isosurface
implementation, so I did so. A little before you wrote this post, I
actually added function-normal calculation so that isoblobs would work
correctly (though I might find a way to go back to the old system
anyway, if I can do so easily). atan2() isn't calculating its normal
correctly, so that I may have to fudge it, but other than that the
function-normal parts can be made to work on isosurfaces as well. I
think this might in some cases be slower than the old normal-finding
method--and in some cases a lot slower--so it might be necessary to
include some sort of flag in the isoblob, as well as in the isosurface
and parametric surface (when I get around to that one) that allows it to
specify the means by which normals are calculated.

Lummox JR


Post a reply to this message

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