POV-Ray : Newsgroups : povray.newusers : arrays and random numbers : Re: arrays and random numbers Server Time
5 Sep 2024 16:19:06 EDT (-0400)
  Re: arrays and random numbers  
From: Chris Huff
Date: 9 Apr 2000 13:46:06
Message: <chrishuff_99-7AC712.12484009042000@news.povray.org>
In article <38EFE55D.ADB3B7E5@fcmail.com>, CMcCabe 
<dea### [at] fcmailcom> wrote:

> i'm sort of assuming that i have something wrong with the way i'm using
> the random number generator, but i'm not entirely sure
> basically i'm trying to assign a random value to that position of the
> array

As Ken explained, you need to pre-declare the seed:
#declare RS = seed(802);
#declare RNum = int(rand(RS));

However, if this is the code you are using, I think you will be running 
into another problem. The int() function operates like this(quoted from 
the manual):

"int(A)
 Integer part of A. Returns the truncated integer part of A. Rounds 
towards zero."

Since the rand() function returns float values between 0 and 1 
inclusively, you will get 0 most of the time, maybe all of the time. You 
need to at least include a multiplier in there:
#declare RNum = int(rand(RS)*Mult);
where Mult>1.

-- 
Christopher James Huff - Personal e-mail: chr### [at] yahoocom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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