POV-Ray : Newsgroups : povray.general : Random-Placement of Objects Server Time
14 Nov 2024 21:15:07 EST (-0500)
  Random-Placement of Objects (Message 1 to 6 of 6)  
From: Sven Littkowski
Subject: Random-Placement of Objects
Date: 9 Feb 2005 10:30:00
Message: <web.420a2c0a5473d9f07e561af90@news.povray.org>
Hi everyone. I need help. I have a scene in which I created an object, so
far it works. At the end of the scene I want to create a random-generated
number how often that object will be placed in the scene (minimum 10x,
maximum 20x), and I also want random-generated locations (x,y,z) and
rotation (again x, y, z axis). That I was not able to do successfully. Who
can help me? Thanks.


Post a reply to this message

From: Tim Nikias
Subject: Re: Random-Placement of Objects
Date: 9 Feb 2005 10:41:10
Message: <420a2f16@news.povray.org>
First, initialize a random stream like this:

#declare Random_Value=seed(12345);

Then, whenever you need a random number between 0 and 1, use
rand(Random_Value).

Multiplying that with values and clipping it with either floor() or ceil()
should get you integers. For example, for a random number between 10 and 20,
do this:
#declare Random_Number = floor(10+10*rand(Random_Value));

Consult the documentation about rand() and seed() for more insight. This
post should only get you started. :-)

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Tom Melly
Subject: Re: Random-Placement of Objects
Date: 9 Feb 2005 10:46:12
Message: <420a3044$1@news.povray.org>
"Sven Littkowski" <wrt### [at] yahoocom> wrote in message
news:web.420a2c0a5473d9f07e561af90@news.povray.org...
> Hi everyone. I need help. I have a scene in which I created an object, so
> far it works. At the end of the scene I want to create a random-generated
> number how often that object will be placed in the scene (minimum 10x,
> maximum 20x), and I also want random-generated locations (x,y,z) and
> rotation (again x, y, z axis). That I was not able to do successfully. Who
> can help me? Thanks.
>
>

Something like:

#declare Rand1 = seed(43552);
#declare ObjCount = int(rand(Rand1)*10)+10;
#declare N = 1;
#while(N<=ObjCount)
  object{
  cylinder{0,y*2,0.25 pigment{Red}}
    rotate<rand(Rand1)*360, rand(Rand1)*360, rand(Rand1)*360>
    translate<rand(Rand1)*10-5,rand(Rand1)*10-5,rand(Rand1)*10-5>
  }
  #declare N=N+1;
#end


Post a reply to this message

From: Neil Kolban
Subject: Re: Random-Placement of Objects
Date: 9 Feb 2005 20:08:08
Message: <420ab3f8$1@news.povray.org>
Sven,
In addition to the other postings, you might want to look at:

http://www.wikipov.org/ow.asp?DropOnSurface

This gives an example of random placement and also demonstrates a technique 
to allow your random objects to be placed on surfaces that might not be 
regular or flat.

Neil

"Sven Littkowski" <wrt### [at] yahoocom> wrote in message 
news:web.420a2c0a5473d9f07e561af90@news.povray.org...
> Hi everyone. I need help. I have a scene in which I created an object, so
> far it works. At the end of the scene I want to create a random-generated
> number how often that object will be placed in the scene (minimum 10x,
> maximum 20x), and I also want random-generated locations (x,y,z) and
> rotation (again x, y, z axis). That I was not able to do successfully. Who
> can help me? Thanks.
>
>


Post a reply to this message

From: Thomas de Groot
Subject: Re: Random-Placement of Objects
Date: 12 Feb 2005 03:39:18
Message: <420dc0b6@news.povray.org>
"Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> schreef in
bericht news:420a2f16@news.povray.org...
> First, initialize a random stream like this:
>
> #declare Random_Value=seed(12345);
>
> Then, whenever you need a random number between 0 and 1, use
> rand(Random_Value).
>
> Multiplying that with values and clipping it with either floor() or ceil()
> should get you integers. For example, for a random number between 10 and
20,
> do this:
> #declare Random_Number = floor(10+10*rand(Random_Value));
>
> Consult the documentation about rand() and seed() for more insight. This
> post should only get you started. :-)
>

Consider also the use of  RRand(Min,Max,Stream) where you can define your
minimum and maximum values directly.

Thomas


Post a reply to this message

From: Sven Littkowski
Subject: Re: Random-Placement of Objects
Date: 17 Feb 2005 11:30:00
Message: <web.4214c67de117e7e2e87562f60@news.povray.org>
FROM THE AUTHOR SVEN LITTKOWSKI:

Thanks to everyone of you all for your nice and helping replies! You all
helped me a lot, and I appreciate it very much. It works well now!

If you are interested to follow up a related question, you can find it
posted in this forum. It is about how to prevent these random-generated
objects are being placed INTO each other.

Sven Littkowski


Post a reply to this message

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