Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/420866759269580800

I am generating positions in a randomly fashingrandom fashion. The in

In the game world instanciated, instantiated elements do have a radius, and shouldn't overlap.

The problem is that they will overlap because I use a usual random number generator combined with other fancynessfanciness. I I can't use other random number generation algorithms where I can guarantee that the elements will never overlap.

A way to solve this is to use a spartial datastructurespatial data structure and search for the nearest neightborsneighbors in that tree. When iI insert a Element toan element into that tree i, I update it accordingly.

This solution would do the work and it would be fast but my question is:

Is there a dedicated algorithm without that Tree implementation complexity which is faster than O(n²)?

I am generating positions in a randomly fashing. The in the game world instanciated elements do have a radius and shouldn't overlap.

The problem is that they will overlap because I use a usual random number generator combined with other fancyness. I can't use other random number generation algorithms where I can guarantee that the elements will never overlap.

A way to solve this is to use a spartial datastructure and search for the nearest neightbors in that tree. When i insert a Element to that tree i update it accordingly.

This solution would do the work and it would be fast but my question is:

Is there a dedicated algorithm without that Tree implementation complexity which is faster than O(n²)?

I am generating positions in a random fashion.

In the game world, instantiated elements have a radius, and shouldn't overlap.

The problem is that they will overlap because I use a usual random number generator combined with other fanciness. I can't use other random number generation algorithms where I can guarantee that the elements will never overlap.

A way to solve this is to use a spatial data structure and search for the nearest neighbors in that tree. When I insert an element into that tree, I update it accordingly.

This solution would do the work and it would be fast but my question is:

Is there a dedicated algorithm without that Tree implementation complexity which is faster than O(n²)?

Source Link
Quonux
  • 1.2k
  • 1
  • 12
  • 19

Exists a dedicated non-O(n²) Algorithm for avoiding to have overlapping elements?

I am generating positions in a randomly fashing. The in the game world instanciated elements do have a radius and shouldn't overlap.

The problem is that they will overlap because I use a usual random number generator combined with other fancyness. I can't use other random number generation algorithms where I can guarantee that the elements will never overlap.

A way to solve this is to use a spartial datastructure and search for the nearest neightbors in that tree. When i insert a Element to that tree i update it accordingly.

This solution would do the work and it would be fast but my question is:

Is there a dedicated algorithm without that Tree implementation complexity which is faster than O(n²)?