New Reply

Simulation Programming: Spawning particles at random position

 
Share Thread Thread Tools
May10-12, 08:34 AM   #1
 

Simulation Programming: Spawning particles at random position


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
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Galaxies fed by funnels of fuel
>> The better to see you with: Scientists build record-setting metamaterial flat lens
>> Google eyes emerging markets networks
May10-12, 01:03 PM   #2
 
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.
May10-12, 02:26 PM   #3
 
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.
New Reply
Thread Tools


Similar Threads for: Simulation Programming: Spawning particles at random position
Thread Forum Replies
I need help programming in Chipmunk Basic with arrow keys, and random coordinate gen. Programming & Comp Sci 3
do particles really emerge from the vacuum at random? Quantum Physics 3
Programming Simulation Software Computing & Technology 0