POV-Ray : Newsgroups : povray.general : Q: Rand Server Time
15 Nov 2024 17:12:10 EST (-0500)
  Q: Rand (Message 1 to 5 of 5)  
From: Ken
Subject: Q: Rand
Date: 1 Jan 1999 07:52:34
Message: <368CC4A7.155EDF35@pacbell.net>
Is it possible to add a random +/- function to a loop ?

For example I have a loop that is making several copies of an object
and I wish to apply a random rotation of say -20*y to +20*y as the
objects are being translated by the loop. Is this possible ?

--
Ken Tyler

tyl### [at] pacbellnet


Post a reply to this message

From: Julius Klatte
Subject: Re: Rand
Date: 1 Jan 1999 09:40:11
Message: <368cde4b.0@news.povray.org>
>Is it possible to add a random +/- function to a loop ?

I think so, yes.

>For example I have a loop that is making several copies of
an object
>and I wish to apply a random rotation of say -20*y to +20*y
as the
>objects are being translated by the loop. Is this possible
?


a random number is between 0 and 1, so if you want to use a
random rotation up to twenty, you can obviously use
20*rand(R) to do the trick
Now if you also wish to use negative numbers up (down?)
to -20, you have to subtract 20,

20*rand(R)-20

This 'creates' numbers between -20 and 0.
If you want numbers between -20 and 20, it would look like
this:

40*rand(R)-20

So your rotation would be like :

#declare seed(R)=1999 (happy new year)
rotate <0,40*rand(R)-20,0>

Hope this helps

Julius
http://surf.to/jkhome


Post a reply to this message

From: Ken
Subject: Re: Rand
Date: 1 Jan 1999 09:42:41
Message: <368CDE77.9818D7D4@pacbell.net>
Julius Klatte wrote:

> >Is it possible to add a random +/- function to a loop ?
>
> I think so, yes.
>
> >For example I have a loop that is making several copies of
> an object
> >and I wish to apply a random rotation of say -20*y to +20*y
> as the
> >objects are being translated by the loop. Is this possible
> ?
>
> a random number is between 0 and 1, so if you want to use a
> random rotation up to twenty, you can obviously use
> 20*rand(R) to do the trick
> Now if you also wish to use negative numbers up (down?)
> to -20, you have to subtract 20,
>
> 20*rand(R)-20
>
> This 'creates' numbers between -20 and 0.
> If you want numbers between -20 and 20, it would look like
> this:
>
> 40*rand(R)-20
>
> So your rotation would be like :
>
> #declare seed(R)=1999 (happy new year)
> rotate <0,40*rand(R)-20,0>
>
> Hope this helps
>
> Julius
> http://surf.to/jkhome

Perfect ! Thank you !

--
Ken Tyler

tyl### [at] pacbellnet


Post a reply to this message

From: Margus Ramst
Subject: Re: Rand
Date: 1 Jan 1999 22:16:10
Message: <368d8f7a.0@news.povray.org>
I created a macro to do exactly that; you can get it from Twyst's
Macroscope; it's called rand_ext.

Margus

Ken wrote in message <368CC4A7.155EDF35@pacbell.net>...
>Is it possible to add a random +/- function to a loop ?
>
>For example I have a loop that is making several copies of an object
>and I wish to apply a random rotation of say -20*y to +20*y as the
>objects are being translated by the loop. Is this possible ?
>
>--
>Ken Tyler
>
>tyl### [at] pacbellnet
>
>


Post a reply to this message

From: Ken
Subject: Re: Rand
Date: 2 Jan 1999 03:37:40
Message: <368DDA69.D291EB77@pacbell.net>
Margus Ramst wrote:

> I created a macro to do exactly that; you can get it from Twyst's
> Macroscope; it's called rand_ext.
>
> Margus

 Thank you. I'll check it out.

--
Ken Tyler

tyl### [at] pacbellnet


Post a reply to this message

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