POV-Ray : Newsgroups : povray.animations : Random Scale Server Time
24 Nov 2024 18:00:55 EST (-0500)
  Random Scale (Message 1 to 4 of 4)  
From: Inexistencia-Design, Dec  P  Eventos Lda
Subject: Random Scale
Date: 17 Mar 1999 08:10:21
Message: <36efa9bd.0@news.povray.org>
Hello!
I need to animate a cylinder by random scaling it up and down in y axis but
a only want to scale from 0.9 to 1.1. How can I get a random number and get
sure that falls between 0.9 and 1.1.
I've tried with rand(seed(clock)) but can't get there.

Sergio


Post a reply to this message

From: Marc Schimmler
Subject: Re: Random Scale
Date: 17 Mar 1999 08:30:20
Message: <36EFAE6B.8418D941@ica.uni-stuttgart.de>
Inexistencia-Design, Dec. P. Eventos Lda wrote:
> 
> Hello!
> I need to animate a cylinder by random scaling it up and down in y axis but
> a only want to scale from 0.9 to 1.1. How can I get a random number and get
> sure that falls between 0.9 and 1.1.
> I've tried with rand(seed(clock)) but can't get there.
> 
> Sergio

Hi Sergio!

I tried this and it worked the I I think you meant.

--------------------------------------------------------
camera {location <0,2,-2>
        look_at  0}

light_source {<1,1,-1> color rgb<1,1,1>}

#declare RAND1 = seed(12345+(clock*10));

cylinder {0,y,0.25 
          pigment{color rgb <1,0,0>}
          scale <1,0.9 + (0.2 * rand(RAND1)),1> }

--------------------------------------------------------

Marc
-- 
Marc Schimmler


Post a reply to this message

From: Ken
Subject: Re: Random Scale
Date: 17 Mar 1999 08:30:41
Message: <36EFADD2.ECA370CA@pacbell.net>
Inexistencia-Design, Dec. P. Eventos Lda wrote:
> 
> Hello!
> I need to animate a cylinder by random scaling it up and down in y axis but
> a only want to scale from 0.9 to 1.1. How can I get a random number and get
> sure that falls between 0.9 and 1.1.
> I've tried with rand(seed(clock)) but can't get there.
> 
> Sergio

  This pair of macros will yield a random-number that varies smoothly
 over time. To use these macros, first #declare an array of four scalars
 and pass it to SmoothSeed( ). The macro will use the array to hold the
 seed( ) values for the four random-number sequences derived from the
 clock variable. Sequence is used to select the sequence to be used for
 generating the random numbers.

 Once SmoothSeed( ) is called, SmoothRand( ) will return a random number
 from 0 to 1. Subsequent calls to the macro within an animation frame will
 vary independently from each other, but the values themselves will vary
 smoothly from frame to frame.

           //example scene code

           #declare MyArray=array[4] {0,0,0,0}

           SmoothSeed(MyArray,0)

           sphere { y*(10+10*SmoothRand(MyArray)),1
             pigment { MyPigment }
           }

When animated, this will give a sphere that rises and falls randomly.
  
 Code: 
           #macro SmoothSeed(Array,Seq)
             #declare Array[0]= seed(floor(clock-1)+Seq);
             #declare Array[1]= seed(floor(clock)+Seq);
             #declare Array[2]= seed(floor(clock+1)+Seq);
             #declare Array[3]= seed(floor(clock+2)+Seq);
           #end

           #macro SmoothRand(Array)
             #local t_T=clock-floor(clock);
             #local t_R0=rand(Array[0]);
             #local t_R1=rand(Array[1]);
             #local t_R2=rand(Array[2]);
             #local t_R3=rand(Array[3]);
             #local t_C0=t_R1;
             #local t_C1=(t_R2-t_R0)*.5;
             #local t_C2=t_R0 - 2.5*t_R1 +2*t_R2-.5*t_R3;
             #local t_C3=-.5*t_R0 +1.5*t_R1 -1.5*t_R2 +.5*t_R3;
             (((((t_C3*t_T+t_C2)*t_T+t_C1)*t_T+t_C0)*.8)+.1)
           #end


-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Josh English
Subject: Re: Random Scale
Date: 17 Mar 1999 15:28:33
Message: <36F010CC.9666D9D1@spiritone.com>
#declare HighPoint = 1.1;
#declare LowPoint = 0.9;
#declare Range = HighPoint - LowPoint;

#declare R1 = seed(42);
#declare MyRandomNumber = rand(R1)*Range + LowPoint;

This gives you a random number between those two points

"Inexistencia-Design, Dec. P. Eventos Lda" wrote:

> Hello!
> I need to animate a cylinder by random scaling it up and down in y axis but
> a only want to scale from 0.9 to 1.1. How can I get a random number and get
> sure that falls between 0.9 and 1.1.
> I've tried with rand(seed(clock)) but can't get there.
>
> Sergio


Post a reply to this message

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