POV-Ray : Newsgroups : povray.newusers : Random Number Generation : Re: Random Number Generation Server Time
5 Sep 2024 10:31:27 EDT (-0400)
  Re: Random Number Generation  
From: Chris Huff
Date: 26 Feb 2001 16:22:58
Message: <chrishuff-411956.16214626022001@news.povray.org>
In article <3A9A89B3.F7059895@spiritone.com>, Josh English 
<eng### [at] spiritonecom> wrote:

> something and something else can be vectors, but they will distribute 
> within a straight line, so you will have to do this in triplicate for 
> three different vectors to fill space.

Triplicate for three different vectors? Not quite, you just need three 
calls to rand()...try these macros:

// "signed rand", ranges from -1 to 1
#macro SRand(RS) (rand(RS)*2 - 1) #end

// "ranged rand"
#macro RRand(Mn, Mx, RS) (Mn + rand(RS)*(Mx-Mn)) #end

// random point in cube from Mn to Mx
#macro RandPt(Mn, Mx, RS)
    (Mn + < rand(RS), rand(RS), rand(RS)>*(Mx-Mn))
#end

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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