POV-Ray : Newsgroups : povray.advanced-users : Implicit loops in function(x,y,z) Server Time
3 Jul 2024 05:15:44 EDT (-0400)
  Implicit loops in function(x,y,z) (Message 9 to 18 of 18)  
<<< Previous 8 Messages Goto Initial 10 Messages
From: Blue Herring
Subject: Re: Implicit loops in function(x,y,z)
Date: 15 Jul 2008 09:47:24
Message: <487caa6c@news.povray.org>
Warp wrote:
> slehar <sle### [at] gmailcom> wrote:
>> So it seems you can't do logical tests on the values of the parameters in a
>> function either!
> 
>   Any #-command is SDL. Any SDL-declared identifier is SDL. You can't use
> them in functions (except to build the function body).

To make things even more confusing, declared functions CAN be called by 
SDL during parse time.  For example:

#declare Foo = function(A) { A + 3 }
#declare Bar = Foo(6);

-- 
-The Mildly Infamous Blue Herring


Post a reply to this message

From: Warp
Subject: Re: Implicit loops in function(x,y,z)
Date: 15 Jul 2008 10:17:58
Message: <487cb195@news.povray.org>
Blue Herring <pov### [at] bherringcotsenet> wrote:
> To make things even more confusing, declared functions CAN be called by 
> SDL during parse time.

  The function name, once #declared, is in the SDL namespace, and the SDL
can call that function. I don't think that's so confusing.

-- 
                                                          - Warp


Post a reply to this message

From: Blue Herring
Subject: Re: Implicit loops in function(x,y,z)
Date: 15 Jul 2008 10:48:04
Message: <487cb8a4$1@news.povray.org>
Warp wrote:
>   The function name, once #declared, is in the SDL namespace, and the SDL
> can call that function. I don't think that's so confusing.

Never thought of it quite like that, that makes a lot of sense.

The distinction, like many other things, becomes largely second nature 
once you work with it enough, in my experience.

-- 
-The Mildly Infamous Blue Herring


Post a reply to this message

From: CoucouHibou
Subject: Re: Implicit loops in function(x,y,z)
Date: 28 Sep 2008 10:05:01
Message: <web.48df8ec326dbfbf05fa61cfc0@news.povray.org>
Hi all,

after some research, I finally found this discussion which talks about a subject
very close to my problem.

I am currently trying to generate a function that interpolates the values of a
physical parameter from a 3-dimensional array. I have the same kind of error
message as what has been posted here, when I use the following code (my array
is named SapceSample, and it has nx*ny*nz elements):

#declare ExtrapFunc=function(px,py,pz){

.... SpaceSample[floor(px)[floor(py)][floor(pz)] ...;

}

The error message is:

Parse Error: ... undeclared identifier 'px'.

So I suppose that when POV-Ray hits the '[', it goes back to the SDL language,
as Warp explained in message #4.

Does anyone know any simple means to go round this problem? Is the only solution
to get a continuous representation of my parameter to define nx*ny*nz functions?

Otherwise, I read some things about the 'density_file' and df3 files. It seems
like that kind of stuff could work for my interpolation, but also that it can
only be used in the scattering media. Is it possible to generate a function
from that?

Thanks a lot for your help,

Hibou


Post a reply to this message

From: Warp
Subject: Re: Implicit loops in function(x,y,z)
Date: 28 Sep 2008 10:25:05
Message: <48df93c1@news.povray.org>
CoucouHibou <wai### [at] yahoofr> wrote:
> Does anyone know any simple means to go round this problem?

  Currently user-defined functions do not support arrays. I don't think
there's any way around this limitation.

> Otherwise, I read some things about the 'density_file' and df3 files. It seems
> like that kind of stuff could work for my interpolation, but also that it can
> only be used in the scattering media. Is it possible to generate a function
> from that?

  You can create a pattern from a df3 file, and consequently you can create
a pattern function from one. You can then call this pattern function with
spatial coordinates and it will return the value of the df3 at those
coordinates (interpolated).

-- 
                                                          - Warp


Post a reply to this message

From: Mike Williams
Subject: Re: Implicit loops in function(x,y,z)
Date: 28 Sep 2008 16:12:49
Message: <YW$5yiA1P+3IFwhT@econym.demon.co.uk>
Wasn't it CoucouHibou who wrote:
>Hi all,
>
>after some research, I finally found this discussion which talks about
>a subject
>very close to my problem.
>
>I am currently trying to generate a function that interpolates the values of a
>physical parameter from a 3-dimensional array. I have the same kind of error
>message as what has been posted here, when I use the following code (my array
>is named SapceSample, and it has nx*ny*nz elements):
>
>#declare ExtrapFunc=function(px,py,pz){
>
>.... SpaceSample[floor(px)[floor(py)][floor(pz)] ...;
>
>}
>
>The error message is:
>
>Parse Error: ... undeclared identifier 'px'.
>
>So I suppose that when POV-Ray hits the '[', it goes back to the SDL language,
>as Warp explained in message #4.

Arrays are always evaluated at parse time, whereas px is only meaningful
at run time.

Inside functions, all you can do with arrays is things like this:
  http://www.econym.demon.co.uk/isotut/arrays.htm

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: CoucouHibou
Subject: Re: Implicit loops in function(x,y,z)
Date: 29 Sep 2008 07:50:01
Message: <web.48e0c02b26dbfbf085d1f9f50@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:

>   You can create a pattern from a df3 file, and consequently you can create
> a pattern function from one. You can then call this pattern function with
> spatial coordinates and it will return the value of the df3 at those
> coordinates (interpolated).

  That is what I did eventually. Thanks for your help.

  Hibou


Post a reply to this message

From: CoucouHibou
Subject: Re: Implicit loops in function(x,y,z)
Date: 3 Oct 2008 12:00:01
Message: <web.48e640cf26dbfbf085d1f9f50@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>
>   You can create a pattern from a df3 file, and consequently you can create
> a pattern function from one. You can then call this pattern function with
> spatial coordinates and it will return the value of the df3 at those
> coordinates (interpolated).

  Hi again,

  I have a little question now. Concerning the interpolate mode in the
density_file command: type 2 interpolation yields weird results! It creates
some big cubic holes in my pattern function while interpolate 1 is correct. I
thought the tricubic interpolation would be smoother and would not show this
mesh-like effect that we can see on the trilinear interpolation, but it seems
to have other defects that can not be compensated for.

  I do not know if this is normal as I do not know much about interpolation
weaknesses (maybe it is just that I have a tricky function, I actually did not
test this on spiral.df3). This is not crucial to my figure, as I compensate for
the lack of smooth interpolation by a higher resolution in the df3, but I am
just curious about it.

  Thanks for your answer,

  Hibou


Post a reply to this message

From: Alain
Subject: Re: Implicit loops in function(x,y,z)
Date: 3 Oct 2008 13:24:54
Message: <48e65566$1@news.povray.org>
CoucouHibou nous illumina en ce 2008-10-03 11:57 -->
> Warp <war### [at] tagpovrayorg> wrote:
>>   You can create a pattern from a df3 file, and consequently you can create
>> a pattern function from one. You can then call this pattern function with
>> spatial coordinates and it will return the value of the df3 at those
>> coordinates (interpolated).
> 
>   Hi again,
> 
>   I have a little question now. Concerning the interpolate mode in the
> density_file command: type 2 interpolation yields weird results! It creates
> some big cubic holes in my pattern function while interpolate 1 is correct. I
> thought the tricubic interpolation would be smoother and would not show this
> mesh-like effect that we can see on the trilinear interpolation, but it seems
> to have other defects that can not be compensated for.
> 
>   I do not know if this is normal as I do not know much about interpolation
> weaknesses (maybe it is just that I have a tricky function, I actually did not
> test this on spiral.df3). This is not crucial to my figure, as I compensate for
> the lack of smooth interpolation by a higher resolution in the df3, but I am
> just curious about it.
> 
>   Thanks for your answer,
> 
>   Hibou
> 
> 
> 

This is a known bug. When the interpolation encounter a zero, it algorythm 
generate some negative values resulting in those ugly artefacts.

A workaround is to have a DF3 file with NO ZERO values, but small values. Then, 
you use a color_map to turn those small values to a zero density.
I've tryed spiral.df3 and interpolate 2, and the result is orrible.

If you want to try the 3.7 beta, it should be corrected.

-- 
Alain
-------------------------------------------------
If Barbie is so popular, why do you have to buy her friends?


Post a reply to this message

From: CoucouHibou
Subject: Re: Implicit loops in function(x,y,z)
Date: 3 Oct 2008 18:40:00
Message: <web.48e69e7f26dbfbf05fa61cfc0@news.povray.org>
Alain <ele### [at] netscapenet> wrote:

> This is a known bug. When the interpolation encounter a zero, it algorythm
> generate some negative values resulting in those ugly artefacts.
>
> A workaround is to have a DF3 file with NO ZERO values, but small values. Then,
> you use a color_map to turn those small values to a zero density.
> I've tryed spiral.df3 and interpolate 2, and the result is orrible.
>
> If you want to try the 3.7 beta, it should be corrected.

  OK, thanks, it should be easy for me to generate a .df3 with no 0 value.
Concerning the 3.7 beta 28, I tried to compile it on my lab's computer, but
there were several errors which I could not correct as I do not know C... But
it is no big deal actually, what I have for the moment is really satisfactory.

  Thanks a lot,

  Hibou


Post a reply to this message

<<< Previous 8 Messages Goto Initial 10 Messages

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