G
G
GreatRash2013-11-12 14:57:29
Unity
GreatRash, 2013-11-12 14:57:29

How to scatter objects over a certain volume without crossing?

Actually the subject: there is a certain volume XYZ, and N objects that should fit in this volume. How to scatter them randomly so that they are guaranteed not to intersect? I came up with a head-on solution:
1) generate random coordinates
2) mark that these coordinates are occupied
3) at the next iteration , check if the coordinates are occupied
4) if they are occupied, then repeat everything again
somewhere after 50 objects, the computer begins to noticeably think. Is there any way to do this faster?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GreatRash, 2013-11-13
@GreatRash

Objects are not of unit size, but space is divided into identical "cells", so the solution is fine. Thank you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question