POV-Ray : Newsgroups : povray.general : keeping functions from looping Server Time
29 Jul 2024 10:24:46 EDT (-0400)
  keeping functions from looping (Message 1 to 3 of 3)  
From: ricky312
Subject: keeping functions from looping
Date: 25 Feb 2012 18:35:01
Message: <web.4f496ef96a4c4bf19fa53fe60@news.povray.org>
I am having trouble with function "looping" they go from rgb 0 to rgb 1 and
repeat over again. is there a way to keep it from doing that with out dividing
the function's "power".
thank you in advance.


Post a reply to this message

From: Zeger Knaepen
Subject: Re: keeping functions from looping
Date: 25 Feb 2012 19:21:25
Message: <4f497b05$1@news.povray.org>
On 26/02/2012 0:30, ricky312 wrote:
> I am having trouble with function "looping" they go from rgb 0 to rgb 1 and
> repeat over again. is there a way to keep it from doing that with out dividing
> the function's "power".
> thank you in advance.


#declare noWrap=function(x) {max(min(x,1),0)}

//now you can do things like:

#declare repeatingFunction=function {x}
#declare nonRepeatingFunction=function{noWrap(repeatingFunction(x))}

//or, very usefull with pigment functions:

#declare troublesomeFunction=function {pigment {image_map {png 
"yourpng.png" interpolate 2}}}

#declare 
notSoTroublesomeFunction_Red=function{noWrap(troublesomeFunction(x,y,z).red)}



Hope this helps!  Don't really know what you mean by "dividing the 
function's power" though, so maybe this is of no use at all to you :)
-- 
ZK


Post a reply to this message

From: ricky312
Subject: Re: keeping functions from looping
Date: 26 Feb 2012 14:25:01
Message: <web.4f4a86367ef482669fa53fe60@news.povray.org>
Zeger Knaepen <zeg### [at] povplacecom> wrote:
> On 26/02/2012 0:30, ricky312 wrote:
> > I am having trouble with function "looping" they go from rgb 0 to rgb 1 and
> > repeat over again. is there a way to keep it from doing that with out dividing
> > the function's "power".
> > thank you in advance.
>
>
> #declare noWrap=function(x) {max(min(x,1),0)}
>
> //now you can do things like:
>
> #declare repeatingFunction=function {x}
> #declare nonRepeatingFunction=function{noWrap(repeatingFunction(x))}
>
> //or, very usefull with pigment functions:
>
> #declare troublesomeFunction=function {pigment {image_map {png
> "yourpng.png" interpolate 2}}}
>
> #declare
> notSoTroublesomeFunction_Red=function{noWrap(troublesomeFunction(x,y,z).red)}
>
>
>
> Hope this helps!  Don't really know what you mean by "dividing the
> function's power" though, so maybe this is of no use at all to you :)
> --
> ZK

Thank you so much; this works perfectly.


Post a reply to this message

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