POV-Ray : Newsgroups : povray.off-topic : Adding adjustable randomness to a sin wave.. : Re: Adding adjustable randomness to a sin wave.. Server Time
3 Sep 2024 13:15:16 EDT (-0400)
  Re: Adding adjustable randomness to a sin wave..  
From: Patrick Elliott
Date: 14 Jan 2011 01:01:03
Message: <4d2fe69f@news.povray.org>
OK. Rethought this a bit.. Here is what I have, pseudo-coded:

//Settings.
noise = 0.5; // (percentage of drift possible)
top = 1; // Top and bottom same = constant level.
bottom = 0;
interval = 0.01;

x = 0;
lval = bottom;
do
   if (noise) rval = rand(1 - noise);
   else rval = 1;

   d = (1 - cos(x * 2 * PI)) * .5; // Get curve point.
   nval = d * rval;
   cval = lval*(1-d) + nval*d;
   //:1: - Other code.
   cval = cval * (top - bottom)) + bottom; // Move to range.
   lval = nval;
   x = x * (x < 1) + interval * (x < 1); // Should cycle back to 0, when 
over 1.
loop (until script closes)

This means that, in principle, I could add in something at :1: that 
could transform the resulting curve into a step, saw tooth, square wave, 
or some mix, in theory, if certain things are set right. For example, 
"noise = 0" would always produce the sin wave, so would be easy to 
"clip/adjust" into something else, in principle. Still thinking on how 
that might be possible...

And finding formulas online to handle it... Gah!

-- 
void main () {

     if version = "Vista" {
       call slow_by_half();
       call DRM_everything();
     }
     call functional_code();
   }
   else
     call crash_windows();
}

<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models, 
3D Content, and 3D Software at DAZ3D!</A>


Post a reply to this message

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