|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
William F Pokorny <ano### [at] anonymousorg> wrote:
> On 10/03/2016 08:06 AM, John Greenwood wrote:
> > #declare Change = true;
> > #declare Function = function( F){select(Change,F,-F)}
> Note there are two select variants. ....
> Then a second form which supports both such transitions and the boolean
> form.
So, the thing(s) to try would be:
#declare Change = true;
#declare Function = function (F) { select(Change, F, F, -F) }
or
#declare Function = function (F) { select(Change, F, -F, -F) }
Correct?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 10/03/2016 10:11 AM, Bald Eagle wrote:
> William F Pokorny <ano### [at] anonymousorg> wrote:
>> On 10/03/2016 08:06 AM, John Greenwood wrote:
>
>>> #declare Change = true;
>>> #declare Function = function( F){select(Change,F,-F)}
>
>> Note there are two select variants. ....
>> Then a second form which supports both such transitions and the boolean
>> form.
>
>
> So, the thing(s) to try would be:
>
> #declare Change = true;
> #declare Function = function (F) { select(Change, F, F, -F) }
>
> or
>
> #declare Function = function (F) { select(Change, F, -F, -F) }
>
> Correct?
>
>
The 'boolean' returns 0 or 1 and so triggers only the last two of the
negative, zero or positive selections in order.
Perhaps play with this code:
#version 3.7;
global_settings { assumed_gamma 1 }
#include "functions.inc"
#debug "\n---\n"
#debug concat("select((1<0),-1.0,0.0,1.0) ==> ",
str(select((1<0),-1.0,0.0,1.0),0,4)," \n")
#debug concat("select(false,-1.0,0.0,1.0) ==> ",
str(select(false,-1.0,0.0,1.0),0,4)," \n")
#debug concat("select((1>0),-1.0,0.0,1.0) ==> ",
str(select((1>0),-1.0,0.0,1.0),0,4)," \n")
#debug concat("select(true,-1.0,0.0,1.0) ==> ",
str(select(true,-1.0,0.0,1.0),0,4)," \n")
#debug concat("select(-1,-1.0,0.0,1.0) ==> ",
str(select(-1,-1.0,0.0,1.0),0,4)," \n")
#debug "---\n"
#error "Stop before actual render for demonstration code."
Bill P.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> The first parameter of the select function acts as a logic switch but does not
> respond correctly to a boolean variable, thus
This is *what you think* it does, but it is not meant to be a logical switch. It
is a mathematical selection, where two or three specific conditions matter in
functions. Please go and read the manual before you complain about behavior you
just don't understand!
BTW, you can get *what you want* with just a simple mathematical expression,
without any function. How to do that is left as an exercise to the reader.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 03.10.2016 um 14:06 schrieb John Greenwood:
> The first parameter of the select function acts as a logic switch
No, it absolutely positively does _not_.
The select function acts as a _threshold_ switch, forming an
indispensible basic building block for piecewise-defined functions.
> 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.
With the `select()` function implemented as a threshold switch, there
would be _no way whatsoever_ to have it also behave consistently as a
boolean switch. Remember that wherever a boolean is expected, _any_
non-zero value is interpreted as `true`, not just positive values.
So in a way it is rather fortunate that `select()` behaviour does _not_
happen to match the behaviour expected of a boolean switch for both
`true` and `false` input values, as that might lead people to
erroneously expect boolean switch behaviour for other input values as
well where it absolutely positively cannot be supported.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
clipka <ano### [at] anonymousorg> wrote:
> Am 03.10.2016 um 14:06 schrieb John Greenwood:
> > The first parameter of the select function acts as a logic switch
>
> No, it absolutely positively does _not_.
> With the `select()` function implemented as a threshold switch, there
> would be _no way whatsoever_ to have it also behave consistently as a
> boolean switch. Remember that wherever a boolean is expected, _any_
> non-zero value is interpreted as `true`, not just positive values.
>
> So in a way it is rather fortunate that `select()` behaviour does _not_
> happen to match the behaviour expected of a boolean switch for both
> `true` and `false` input values, as that might lead people to
> erroneously expect boolean switch behaviour for other input values as
> well where it absolutely positively cannot be supported.
Ah. I understand. Thanks for the clear explanation.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|