THIS IS A POST ABOUT THE MATH OF US, IF IT DOESN'T INTEREST YOU, JUST DON'T READ IT

How are you calculating these numbers?

5 bodies: 15 calculations

20 bodies: 360 calculations

100 bodies: 9800 calculations

Since each body compares itself to every other... The math should be:

5 bodies: 5x4 = 20 force calculations

20 bodies: 20x19 = 380 force calculations

100 bodies: 100x99 = 9900 force calculations

I thought that when you calculate the forces of the bodies you obtain n-1 (e.g. 5-1 = 4) forces for each body, (where n is the number of bodies), so you have n-1 (4) vectors that have to be sum in order to have 1 resultant (I think that this is the passage different, maybe just in the order), so you have to do n-2 ((n-1)-1) vectorial sum as, for example, to obtain a resultant from 4 vectors you have to do 3 sums... All of this for each body, so I obtained the equation c (calculations) = (n-2)*n

e.g. 5: c = (5-2)*5 = 15

...and so on

Probably the passage different is the 2nd: i supposed that firstly US calculates all the forces for each body, and then it calculates the resultants before converting it to acceleration.

4 - There are also checks for collisions between every object.

I've forgot it... I think that US checks the radius of all the bodies and when 2 bodies are at a distance less than the sum of the radiuses there is a collision so, again, like for the gravity formula, there is a calculation per couple of bodies ==> for 5 bodies there are 10 calculation, 190 for 20, and so on...

Totally, without considering the calculation for the collisions themselves there would be:

5: 41 calculation per frame * 20 fps = 820 calculations per second

20: 731 cpf * 20 fps = 14620 cps

100: 19801 cpf * 20 fps = 396020 cps

Again, I hope they are correct.

Probably during a collision in combine mode, the mass is summed, the velocity is calculated, considering the kinetic energy and the quantity of mote for the module, and using another vectorial sum for the direction (however i'm not sure of this because at school we made only the collisions on a straight line).

In the bounce mode, when there is an elastic collision (so that the 2 bodies doesn't remain attached) it uses the same formulas, but it needs double calculation because the bodies remain separated (so 2 velocities to be calculated).

Other 2/4 calculation per collision.

What happens exctly when the 2 bodies, in the bounce mode, remain attached, escapes from my immagination and deduction...

Basically there is a collision per frame, but the position of the 2 bodies must be changed so that they don't "fall" into each other. Can't imagine the enormus amount of calculation where there are many bodies attached in a group (e.g. the systems "Moon - large/small cluster, flat disk" or even in "dice swarm" where the shape is cubic and not spherical). I cannot imagine the calculations for the velocities too...

Well i think, Dan, that you made an excellent work with this simulator