|
![](/i/fill.gif) |
"Bald Eagle" <cre### [at] netscape net> wrote:
> I figure I'll put this here, rather than embedding it in the midst of other
> threads.
>
> I'm currently working out some code to create some piece-wise functions with
> very specific constraints.
>
> During development, I noticed some odd mismatches, seemingly resulting from the
> manner in which 3-argument select () statements work.
>
> Using the 4-argument form and (repeating the equation to evaluate after a comma)
> doesn't seem to correct this.
>
> Specifically, each section of the piece-wise function never reaches the end of
> its domain, and instead, the next section of the nested select statement starts
> getting evaluated.
> I shifted the 2nd segment up a bit to illustrate the problem in the attached
> image. (disregard the file name)
I'm sorry Bill, but you have to provide some more information for us about
what you are doing here.
> https://wiki.povray.org/content/Reference:Numeric_Expressions
> select(A, B, C [,D])
> It can be used with three or four parameters Select compares the first argument
> with zero, depending on the outcome it will return B, C or D. A,B,C,D can be
> floats or fun(c)tions.
> When used with three parameters, if A < 0 it will return B, else C (A >= 0).
> When used with four parameters, if A < 0 it will return B. If A = 0 it will
> return C. Else it will return D (A > 0).
>
>
>
> Maybe that's something that I'm doing wrong, or maybe there's a hidden issue
> with select () that's never been uncovered yet.
>...
> But it did make me think that there ought to be a way to reverse which "side" of
> the evaluation A = 0 gets included in:
>...
There already is a way:
select(A, B, C)
A < 0: return B
A = 0: return C
A > 0: return C
select(-A, C, B)
A < 0: return B
A = 0: return B
A > 0: return C
select(E - F, G, H)
E < F: return G
E = F: return H
E > F: return H
select(F - E, H, G)
E < F: return G
E = F: return G
E > F: return H
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
![](/i/fill.gif) |