POV-Ray : Newsgroups : povray.advanced-users : operator (or variable?) substitution in a function? : Re: operator (or variable?) substitution in a function? Server Time
6 Oct 2024 13:47:15 EDT (-0400)
  Re: operator (or variable?) substitution in a function?  
From: Kenneth
Date: 27 Oct 2006 01:25:00
Message: <web.454196aa5e545f214f827d3b0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
#declare bender = .2*sin(1*pi*y + 5);
>
> One of the things that's going on is that "y" has two different meanings
> in POV. When you're using it in a parse-time variable, like that, it's
> interpreted as the vector <0,1,0>.

A new discovery for me.  Thanks.
>
> Another thing that's going on is that you don't want "bender" to be
> evaluated at parse time. That would effectively make it behave like a
> constant during the render.

Yes, I did have a vague notion that this might be happening... but was
hoping not!  ;-)

> You want it to be a function that varies
> with y during the render, so that different parts of the object are bent
> by different amounts.

I understand completely. (Though I have to admit, I'm still a bit fuzzy on
which things happen during parsing and which during rendering.  But your
explanation has helped close that gap.)
>
> #declare bender = function(y){ .2*sin(1*pi*y + 5)}

Excellent!  Thanks so much. I wouldn't have thought of that. I also see that
I need to use brackets (around the expression) rather than parentheses.
Because it's a function. Ohhhh....
>
> Then you can write things like
>
> isosurface{
>   function {
>     sqrt( pow(x+bender(y),2) + pow(z,2)) -0.05
>   }

Just what I was looking for.  Thanks for "opening my eyes."  This technique
will be VERY useful.

Ken


Post a reply to this message

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