POV-Ray : Newsgroups : povray.general : select, is this logical? : Re: select, is this logical? Server Time
29 Apr 2024 02:20:15 EDT (-0400)
  Re: select, is this logical?  
From: William F Pokorny
Date: 3 Oct 2016 09:30:45
Message: <57f25d85$1@news.povray.org>
On 10/03/2016 08:06 AM, John Greenwood wrote:
> The first parameter of the select function acts as a logic switch but does not
> respond correctly to a boolean variable, thus
>
>   #declare Change = true;
>   #declare Function = function( F){select(Change,F,-F)}
>
> gives the same result for Change = false
>
>   #declare Function = function( F){select(-Change,F,-F)}
>
> works.
>
> This is not consistant, but I suppose we are stuck with it.
>
>

Note there are two select variants. One with the traditional two options 
you not above and a second with three select options of negative, zero 
and positive. It is this latter form you want to use if your test 
returns a boolean result.

I too trip over the behavior on occasion which is documented at:

  http://wiki.povray.org/content/Reference:Numeric_Expressions#Functions

Supposing to answer for those smarter than me who architect-ed the 
current behavior, I believe the idea was to go with a default select 
operation which would work first with the bulk of the built in functions 
which tend to always transition through zero.

Then a second form which supports both such transitions and the boolean 
form.

In other words, I think they were first considering things from a 
mathematical view as opposed to a programming one.

Bill P.


Post a reply to this message

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