Simulation Programming: Spawning particles at random position

AI Thread Summary
The discussion revolves around a simulation project using Breve, where the user is trying to spawn spherical particles with random radii in a designated area without overlapping. The initial brute force method involves checking the distance between new and existing particles to ensure they do not overlap, which is effective but inefficient, especially with a large number of particles, leading to long processing times and potential program crashes. To improve efficiency, the user seeks a method to initially select a random position for new particles and, if overlaps occur, quickly find a new position that does not intersect with existing spheres. This approach aims to reduce the number of checks and enhance the program's performance.
PythagoreLove
Messages
19
Reaction score
0
Hi, I am making a program with the simulation software Breve. It codes in Python or in Steve (their own language). In my simulation, spherical particle with random radius are being spawned at random position into a little zone. My problem is that those particle cannot be superposed. I don't know how to program it in such a way that the particle will spawn at a position where they will touch no other particle.


Thanks
PytLove
 
Technology news on Phys.org
Simple brute force method:

For each new particle check to see the distance between the center of the particle and the center of each previous particle is greater than the sum of the radius of each of those two particles. If it isn't then throw the new one away and generate another particle.
 
Thank you that seems to work well. Unfortunately that takes a long time with a lot of sphere and sometimes the program crash because the loop verifying the sphere position run for too much time. I would like to at first take a random position, and if it touches another sphere choose a position where there is nothing. In that way one sphere could not be spawned more than two times. I don't know if it's possible but I think that could make my program faster.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top