![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In my previous post I talked about adding random translation/rotation into
my tunnel building script. I've played around with the rand() function with
mixed results. From what I understand it works like so
#declare myseed = seed(12);
translate <0,0,rand(myseed)>
The problem with this is that the random value you get is only between 0 and
1. SO I tried the following.
translate <0,0,rand(myseed)/rand(myseed)> or
translate <0,0,rand(myseed)/rand(myseed)*rand(myseed)>
This does work better but I still don't get the effect I want. With this
method most of the objects are still only translated an imperceptible
amount, and then every once in a while an object will be translated a large
distance. What I want is for all the objects to be noticeably translated a
random amount, but I don't want any sudden leaps.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
From: Dave Blandston
Subject: Re: Question on introducing randomness.
Date: 12 May 2001 20:05:42
Message: <3afdcfd6@news.povray.org>
|
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Random numbers are lots of fun. Generally, you need to multiply the random
number by some amount and then add or subtract a constant in order to get
random numbers within the range that you want. For example, if you want real
random numbers between 20 and 25, you could do this:
#local NewZ = rand (MySeed) * 5 + 20;
If you want integer random numbers between -3 and 3, you could do this:
#local NewZ = int (rand (MySeed) * 7) - 3;
Here's one more example: To get numbers between .2 and .3, you could use
this:
#local NewZ = rand (MySeed) * .1 + .2;
Have fun,
Dave Blandston
--------------------------------------
"Thomas Lake" <tla### [at] home com> wrote in message
news:3afdcb2e$1@news.povray.org...
> In my previous post I talked about adding random translation/rotation into
> my tunnel building script. I've played around with the rand() function
with
> mixed results. From what I understand it works like so
>
> #declare myseed = seed(12);
>
> translate <0,0,rand(myseed)>
>
> The problem with this is that the random value you get is only between 0
and
> 1. SO I tried the following.
>
> translate <0,0,rand(myseed)/rand(myseed)> or
> translate <0,0,rand(myseed)/rand(myseed)*rand(myseed)>
>
> This does work better but I still don't get the effect I want. With this
> method most of the objects are still only translated an imperceptible
> amount, and then every once in a while an object will be translated a
large
> distance. What I want is for all the objects to be noticeably translated a
> random amount, but I don't want any sudden leaps.
>
>
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Thanks for the info! I'm trying to find out how to create random numbers
between -0.75 and 0.75. I tried to come up with the function using your
examples but I can't seem to get it right. The general for seems to be
Num = rand*x + y
so
-0.75 = 0.1*x +y and
0.75 = 0.9*x +y
I've tried solving for x and y, buy graphing and calculating the
intersection of the 2 lines, but this doesn't work.
"Dave Blandston" <gra### [at] earthlink net> wrote in message
news:3afdcfd6@news.povray.org...
> Random numbers are lots of fun. Generally, you need to multiply the random
> number by some amount and then add or subtract a constant in order to get
> random numbers within the range that you want. For example, if you want
real
> random numbers between 20 and 25, you could do this:
> #local NewZ = rand (MySeed) * 5 + 20;
>
> If you want integer random numbers between -3 and 3, you could do this:
> #local NewZ = int (rand (MySeed) * 7) - 3;
>
> Here's one more example: To get numbers between .2 and .3, you could use
> this:
> #local NewZ = rand (MySeed) * .1 + .2;
>
> Have fun,
> Dave Blandston
> --------------------------------------
>
> "Thomas Lake" <tla### [at] home com> wrote in message
> news:3afdcb2e$1@news.povray.org...
> > In my previous post I talked about adding random translation/rotation
into
> > my tunnel building script. I've played around with the rand() function
> with
> > mixed results. From what I understand it works like so
> >
> > #declare myseed = seed(12);
> >
> > translate <0,0,rand(myseed)>
> >
> > The problem with this is that the random value you get is only between 0
> and
> > 1. SO I tried the following.
> >
> > translate <0,0,rand(myseed)/rand(myseed)> or
> > translate <0,0,rand(myseed)/rand(myseed)*rand(myseed)>
> >
> > This does work better but I still don't get the effect I want. With this
> > method most of the objects are still only translated an imperceptible
> > amount, and then every once in a while an object will be translated a
> large
> > distance. What I want is for all the objects to be noticeably translated
a
> > random amount, but I don't want any sudden leaps.
> >
> >
>
>
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
From: Christoph Hormann
Subject: Re: Question on introducing randomness.
Date: 13 May 2001 04:36:16
Message: <3AFE47CB.A8284B9F@gmx.de>
|
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Thomas Lake wrote:
>
> Thanks for the info! I'm trying to find out how to create random numbers
> between -0.75 and 0.75. I tried to come up with the function using your
> examples but I can't seem to get it right. The general for seems to be
>
> Num = rand*x + y
>
where x is the range of values and y the center minus half the range (or
the lowest value):
#declare Num = rand(Seed)*1.5 - 0.75;
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <3afe4401$1@news.povray.org>, tla### [at] home com says...
> Thanks for the info! I'm trying to find out how to create random numbers
> between -0.75 and 0.75. I tried to come up with the function using your
> examples but I can't seem to get it right. The general for seems to be
This macro returns a random number between R_min and R_max
in your case use random(MySeed,-0.75,0.75)
#macro random(Myseed,R_min,R_max)
(rand(MySeed)*(R_max-R_min) + R_min)
#end
> Num = rand*x + y
> so
> -0.75 = 0.1*x +y and
> 0.75 = 0.9*x +y
Wrong.
-0.75 = 0*x+y
0.75 = 1*x+y
so
y = -0.75 // = R_min
x = 2*0.75 = 0.75 - (-0.75) // = R_max - R_min
Lutz-Peter
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
I forget where I found this, but I've had it awhile.
#macro rand_ext(M,D,Seed)
(M+(rand(Seed)-.5)*2*D)
#end
This macro returns a random number in a range where M is the mean value, D
is the negative and positive deviation from this mean, and Seed is a
seed([number]) value.
For instance, the line #declare fromfivetofifteen=rand_ext(10,5,seed(123));
would return a random value between 5 and 15.
-Chris-
Thomas Lake <tla### [at] home com> wrote in message
news:3afdcb2e$1@news.povray.org...
> In my previous post I talked about adding random translation/rotation into
> my tunnel building script. I've played around with the rand() function
with
> mixed results. From what I understand it works like so
>
> #declare myseed = seed(12);
>
> translate <0,0,rand(myseed)>
>
> The problem with this is that the random value you get is only between 0
and
> 1. SO I tried the following.
>
> translate <0,0,rand(myseed)/rand(myseed)> or
> translate <0,0,rand(myseed)/rand(myseed)*rand(myseed)>
>
> This does work better but I still don't get the effect I want. With this
> method most of the objects are still only translated an imperceptible
> amount, and then every once in a while an object will be translated a
large
> distance. What I want is for all the objects to be noticeably translated a
> random amount, but I don't want any sudden leaps.
>
>
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |