POV-Ray : Newsgroups : povray.advanced-users : Randomly timed events : Re: Randomly timed events Server Time
28 Sep 2024 18:34:37 EDT (-0400)
  Re: Randomly timed events  
From: Bald Eagle
Date: 29 Aug 2013 11:35:01
Message: <web.521f69a1fc2c9d36dd2ebc560@news.povray.org>
> I guess you probably meant to write:
>
> #if( rand(Flash) = clock )

Oops.  Late-night POV coding strikes again.

> But that won't work as you want, because rand() returns a float between
> 0 and 1 and it's extremely unlikely to ever equal your clock value.

Yes, that's what I was worried about, and with some food and coffee fueling the
brain, I can likely see just how probable the unlikelihood of the clock and
random number probably, or improbably matching is, or isn't.  Though that could
change.  :D

>If  you want your flash to last just one frame try something like:
>
> #declare Flash = seed(1);
> ...
> #declare flashFrame = int( rand(Flash) * final_frame);
> #if( frame_number = flashFrame)
> ...
>
> Or if you want your flash to last a specific amount of clock (eg 0.1):
>
> #declare flashStart = rand(Flash) * final_clock;
> #if( clock>flashStart & clock<flashStart+0.1)
> ...
>
> Note this will create the flash at exactly the same frame every time you
> run the animation - because the first random number generated after
> seed(1) is always the same.

_Most_ excellent.  That instantly cleared up that little problem.

I think if I consider the pseudorandom numbers as simply a library of selctable
one-dimensional arrays, it will be less confusing than "Hey, I need a 'random'
number" - because they're NOT.

I was also considering defining an object such as an image_map of noise, or a
cloud, and then just grabbing a pixel value, though I don't know if adding
layers of convolution get me anything better than declaring the seed value for
each frame with the clock value...  #declare RanDUMB_Number = seed (clock)


Post a reply to this message

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