POV-Ray : Newsgroups : povray.unofficial.patches : isosurface/function question : Re: isosurface/function question Server Time
1 Sep 2024 20:16:00 EDT (-0400)
  Re: isosurface/function question  
From: Chris Huff
Date: 10 Nov 2000 07:18:10
Message: <chrishuff-B5922A.07172510112000@news.povray.org>
In article <3a0b8584$1@news.povray.org>, Ken Cecka <cec### [at] homecom> 
wrote:

> I've just started playing around with isosurfaces in MP0.6a, and have 
> been a little confused about what keywords are/aren't alowed when 
> defining functions.  In particular, I wanted to use the rand() 
> function, but I get the error "float factor expected but rand found 
> instead".  As far as I know, rand() returns a float factor, so this 
> error doesn't make sense to me.  Are function expressions parsed 
> differently than other pov code so that they only allow a particular 
> subset of the available functions? 

Yes. Instead of calling the functions immediately, the function is read 
and used to create a data structure that can be quickly evaluated 
multiple times during rendering. The rand() function would be useless 
here, it would just return a new value *every time the function was 
evaluated*, making it impossible for the isosurface algorithm to find a 
surface.(though it still could be useful for some patterns and if 
functions are allowed to be called in scene code)
Not all functions which return floats are allowed, there is a list of 
allowed keywords in the documentation. (5.2.12. New keywords / operators 
for the isosurface patch)

To do what you want, declare a variable with the random number and use 
that variable in the function. This will calculate *one* random number 
and use it in the function, instead of calculating a new one every time 
the function is used.


> P.S.  Another question I had, which I am getting the impression is a 
> feature which is not yet avaiable, was how to define functions which 
> accept variables like the builtin functions do.  Is this possible, or 
> does have to be done by building the function in a precompiled 
> library?

It is currently impossible without modifying the source. And be aware 
that the built in functions probably won't make it into POV 3.5.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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