|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I know how to create local variables in a macro, but after extensive
searching, I still have not found any way to create local variables in a
function. Is this even possible?
Just for a crazy example, suppose I had something like this:
#declare f=function(x) {sum(i,1,1000,pow(sin(x),i))}
Then it would be much faster if I could make a local variable, say,
something like this:
#declare f=function(x) {sinx=sin(x); sum(i,1,1000,pow(sinx,i))}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I dont believe it is possibl old chum, it's a math only thing.... as opposed
to a programatic thing.
--
#####-----#####-----#####
POV Tips and Hints at ...
http://povman.blogspot.com/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it bugman who wrote:
>I know how to create local variables in a macro, but after extensive
>searching, I still have not found any way to create local variables in a
>function. Is this even possible?
>
>Just for a crazy example, suppose I had something like this:
>#declare f=function(x) {sum(i,1,1000,pow(sin(x),i))}
>
>Then it would be much faster if I could make a local variable, say,
>something like this:
>#declare f=function(x) {sinx=sin(x); sum(i,1,1000,pow(sinx,i))}
Within a function, you can't set the value of a variable
If you're using this particular function to produce results for
individual values of x, rather than using it for an isosurface or
pigment where x varies beyond the reach of the SDL, then you could pass
the variable as a parameter:
#declare f=function(sinx) {sum(i,1,10000000,pow(sinx,i))}
#debug str( f(sin(0.1)),-1,-1 )
However, it turns out to only be 13% faster than writing
#declare f=function(x) {sum(i,1,10000000,pow(sin(x),i))}
#debug str(f(0.1),-1,-1)
It looks like evaluating sin(x) is incredibly efficient in POV
functions.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
bugman wrote:
> I know how to create local variables in a macro, but after extensive
> searching, I still have not found any way to create local variables in a
> function. Is this even possible?
Unfortunately the syntax of functions (which is completely
distinct from the syntax of the SDL) is quite limited compared
to the SDL. Using variables is one of the things it does not
(yet) support.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wow, thanks for the prompt replies!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
OK, I have a slightly different question. Is there any way to extract an
array element in a function? For example:
#declare xlist=array[3] {5.5,2.1,7.8};
#declare getx=function(i) {xlist[int(i-1)]};
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it bugman who wrote:
>OK, I have a slightly different question. Is there any way to extract an
>array element in a function? For example:
>
>#declare xlist=array[3] {5.5,2.1,7.8};
>#declare getx=function(i) {xlist[int(i-1)]};
The nearest I've managed to get is this:
http://www.econym.demon.co.uk/isotut/arrays.htm
You can use the individual elements of arrays, but you can't index an
array from inside a function.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
If you are really set on feeding raw data into functions,
you can use an image map pigment function, and edit
an image to contain your data in one of the color channels.
#declare TooFun = function {
pigment {
image_map {
tga "fun_map.tga"
}
}
};
#declare TooFunX = function(x) {
TooFun(x,0,0).x
};
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks for the clever ideas.
Here is the fruit of my labor:
http://bugman123.com/Physics/Magnets.m1v
My approach was to automatically write lengthy functions in include files.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"bugman" <nomail@nomail> wrote:
> Thanks for the clever ideas.
>
> Here is the fruit of my labor:
> http://bugman123.com/Physics/Magnets.m1v
>
> My approach was to automatically write lengthy functions in include files.
Here is another one:
http://bugman123.com/Physics/Motor.m1v
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |