POV-Ray : Newsgroups : povray.advanced-users : rand help : Re: rand help Server Time
29 Jul 2024 22:30:16 EDT (-0400)
  Re: rand help  
From: Margus Ramst
Date: 3 Dec 2000 15:50:40
Message: <3A2AB293.B7D70000@peak.edu.ee>
"Laurence M. Salme" wrote:
> 
> I need help understanding how to use rand and seed. I figure a random of
> .75 to 1.0 may be needed for an image i'm working on.

Try these macros. For example to get a random number from 0.75 to 1 you'd have
to specify rand_ext(.875,.125,Seed) where Seed is a declares random number seed.

//Create random number of given mean and maximum deviation
//M - mean value
//D - maximum deviation
//Seed - (declared) random number seed identifier
#macro rand_ext(M,D,Seed)
        (M+(rand(Seed)-.5)*2*D)
#end

//Give a random vector of given mean and max deviation
//M - mean (vector/float)
//D - max deviation (vector/float)
//Seed - (declared) random number seed identifier
#macro v_rand_ext(M,D,Seed)
        #local MV=M+<0,0,0>;
        #local DV=D+<0,0,0>;
       
(<rand_ext(MV.x,DV.x,Seed),rand_ext(MV.y,DV.y,Seed),rand_ext(MV.z,DV.z,Seed)>)
#end


-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg
Home page http://www.hot.ee/margusrt


Post a reply to this message

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