POV-Ray : Newsgroups : povray.binaries.images : Placing random spheres (~330k in attachments) : Placing random spheres (~330k in attachments) Server Time
7 Aug 2024 07:12:12 EDT (-0400)
  Placing random spheres (~330k in attachments)  
From: Warp
Date: 15 May 2006 16:48:16
Message: <4468e90a@news.povray.org>
Inspired by a post I made to another group, I thought if I could find
a fast way to create a large amount of randomly-placed spheres on a plane
so that they don't intersect each other.

  In these images I created 5000 spheres randomly placed inside an area
between <-10, 0, -10> and <10, 0, 10>. The locations of each sphere is
individually calculated with just a honest
MinCoords+(MaxCoords-MinCoords)*<rand(Seed), 0, rand(Seed)>
ie. no cheating by creating repeating patterns which just look random
or anything. The location of each sphere is honestly calculated by
with that line.

  In the first image the radius of the spheres is 0.2 and it took
17 seconds to parse in my P4 3.4GHz. In the second image the radius
is 0.23 and it took a lot longer because the space fills faster and
it's harder to find places for new spheres: 2 minutes 44 seconds.

  The naive way of doing this (which I posted in that another group)
took more than 7 minutes to place the spheres of radius 0.2 (compared
to the 17 seconds of my optimized method). I don't know how much longer
than 7 minutes it is because I got bored of waiting and stopped it.

  The scene which created these images is 76 lines long (written in
a nice, indented way, no obfuscation nor artificial shortening, and
it even prints its progress during the calculations).

  If you want a small challenge, try replicating this result.


Post a reply to this message


Attachments:
Download 'randspheres_radius0.2.jpg' (160 KB) Download 'randspheres_radius0.23.jpg' (164 KB)

Preview of image 'randspheres_radius0.2.jpg'
randspheres_radius0.2.jpg

Preview of image 'randspheres_radius0.23.jpg'
randspheres_radius0.23.jpg


 

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