|
|
"Bill Pragnell" <bil### [at] hotmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> > I still don't know the algorithm or technique for placing randomly-located
> > objects that don't overlap, each object having its own space...
>
> You can store objects in an array, and check each new one against existing
> positions and bounds, for example in dodgy pseudocode:
[snip]
>
> Alternatively, you can subdivide your region of interest, then pick a single
> random location in each sub-region. This has the advantage of not requiring
> extensive looping and testing, although subdivision might be non-trivial. For
> rectangles it's not too bad.
>
> If your objects are all roughly the same sort of size, you can lay a grid
> down, perturb the grid positions by some distance smaller than the grid
> spacing, then place objects at the perturbed grid positions. Using only
> a subset of the grid positions makes it look more random.
>
Thanks a bunch! You've given me some good ideas to pursue. Btw, while trying to
come up with workable schemes 'on my own', I'm happy to say that the
grid-subdivision idea(s) did occur to me at various times, in rather fuzzy
ways-- but I didn't follow up on them. :-( It's nice to know that I wasn't too
far off in my thinking.
And it looks like POV-ray's min_extent(...) and max_extent(...) tools will be
useful here, especially since my greebles are of various sizes and shapes.
Post a reply to this message
|
|