POV-Ray : Newsgroups : povray.advanced-users : using the select() function for evaluating conditioinals at runtime Server Time
29 Jun 2024 02:19:42 EDT (-0400)
  using the select() function for evaluating conditioinals at runtime (Message 1 to 3 of 3)  
From: ghostch
Subject: using the select() function for evaluating conditioinals at runtime
Date: 26 Aug 2009 18:45:00
Message: <web.4a95ba727ac00785dea286ee0@news.povray.org>
hi
i am having multiple functions defined in povray, that all return a float value,
now i would like to have povray select a specific function from them depending
on a given coordinate (at runtime!). i think is saw someone using a statement
like
select((x>10&x<40), f1(x,y,z), f2(x,y,z))
*inside* a function but i am having no luck with that. there is no warning or
error, but povray seems to ignore the conditional statement.
is someone able to explain this to me?
thx,
Simon


Post a reply to this message

From: ghostch
Subject: Re: using the select() function for evaluating conditioinals at runtime
Date: 26 Aug 2009 18:50:00
Message: <web.4a95bbd085832818dea286ee0@news.povray.org>
here is where i saw it...
http://news.povray.org/gg%24T6rCHpDfIFw14%40econym.demon.co.uk


Post a reply to this message

From: Reactor
Subject: Re: using the select() function for evaluating conditioinals at runtime
Date: 26 Aug 2009 19:05:00
Message: <web.4a95be9c8583281830d437200@news.povray.org>
"ghostch" <nomail@nomail> wrote:
> hi
> i am having multiple functions defined in povray, that all return a float value,
> now i would like to have povray select a specific function from them depending
> on a given coordinate (at runtime!). i think is saw someone using a statement
> like
> select((x>10&x<40), f1(x,y,z), f2(x,y,z))
> *inside* a function but i am having no luck with that. there is no warning or
> error, but povray seems to ignore the conditional statement.
> is someone able to explain this to me?
> thx,
> Simon


If you check the docs on select, you will see that it compares the first
argument with zero.  If it is less than zero, it will return the second
argument.  If it is greater than or equal to, it will return the second
argument.  In this case, ( x > 10 & x < 40 ) is always greater than or equal to
zero, since it is either true (1) or false (0).  When do you want to return
f1(x,y,z),  condition-wise, as opposed to returning f2(x,y,z)?  If you want f1
unless that statement is true, you can just subtract 1 from the first argument.

-Reactor


Post a reply to this message

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