POV-Ray : Newsgroups : povray.beta-test : bug: select within select : Re: bug: select within select Server Time
4 Nov 2024 19:24:03 EST (-0500)
  Re: bug: select within select  
From: Mike Williams
Date: 1 Oct 2001 14:20:00
Message: <C5fbDCACOLu7EwXB@econym.demon.co.uk>

>POV 3.5b4 on PII233 128 MB with NT4Sp6
>
>it looks like select inside select not work
>
>look at the function
>
>#local test=function{
>        select(
>          f_noise3d(floor(x),floor(y),0)-(1/3),
>          0,
>          select(
>            f_noise3d(floor(y),floor(x),0)-(1/2),
>            1,
>            2
>          )
>        )
>      }
>
>in my opionion it should evenly return 0, 1 and 2
>
>but I have tested this 100.000 with differents seeds and random points
>with script from the end of this post and it returned
>
>0 - 0 times
>1 - 64161 times
>2 - 35839 times
>
>anybody can confirm ?

I confirm the numbers, but I don't think it's anything to do with the
nesting of selects.

If you change to noise generator 1, the numbers come out even. It looks
to me like there's a subtlety in noise type 3 that causes
f_noise3d(integer, integer, 0) to always be greater than 1/3. I really
don't see that as being a problem because you shouldn't really expect
noise3d to be a random number generator.

[[But, does that actually mean that we don't have a decent random number
generator that we can use in a function? Rand() is not available inside
a function block.]] 

Adding:
        global_settings{
          noise_generator 1
        }       
to your scene gives the results:

0 - 35946 times
1 - 32982 times
2 - 31072 times

Which indicates that the nested selects are working perfectly, and
noise_generator 1 does happen to partition (floor(x),floor(y),0) into
three roughly equal thirds.


If you do the same thing, with the default noise generator, but without
the "floor()"s, then the results are:-

#local test=function{
        select(
          f_noise3d(x,y,0)-(1/3),
          0,
          select(
            f_noise3d(y,x,0)-(1/2),
            1,
            2
          )
        )
      }

0 - 13007 times
1 - 45476 times
2 - 41517 times



By the way, since you seem to like using "Interpolate()", I guess that
you have some idea of what it's supposed to do and what the parameters
mean. Would it be possible for you to enlighten the rest of us? The docs
have a bit of a hole there.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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