@RonJeffries I was trying things with just two balls and with the speed below a certain limit. Even setting the restitution to 2 or higher, when the 2 balls collided, they just stopped. When I would go just 1 above that speed limit, the balls went crazy on each collision with a high restitution. So I would say there’s a speed limit for physics to work right.
@RonJeffries Heres some code to show the speed limit for 2 balls to bounce off each other. A speed of 16 or less doesn’t cause a bounce while a speed greater than 16 does. I can set linearDamping to a negative number, but that just causes the balls to speed up with multiple collisions in the other program. Change the speed value to see the bounce, no bounce.
displayMode(STANDARD) function setup() physics.continuous=true physics.gravity(0,0) speed=16 create1() create2() end function draw() background(0) fill(255) ellipse(a1.x,a1.y,20) ellipse(a2.x,a2.y,20) v=a1.linearVelocity text(v.y,a1.x+80,a1.y) v1=a2.linearVelocity text(v.y,a2.x+80,a2.y) end function create1() a1=physics.body(CIRCLE,10) a1.sleepingAllowed=false a1.linearDamping=0 a1.restitution=1 a1.mass=1 a1.friction=0 a1.x=WIDTH/2 a1.y=HEIGHT/2-50 a1.linearVelocity=vec2(0,speed) end function create2() a2=physics.body(CIRCLE,10) a2.sleepingAllowed=false a2.linearDamping=0 a2.restitution=1 a2.mass=1 a2.friction=0 a2.x=WIDTH/2 a2.y=HEIGHT/2+50 a2.linearVelocity=vec2(0,-speed) end
@dave1707 i was intrigued by the bouncing problem and went to the Box2D documentation. It seems there is a default velocity threshold (1) below which the collisions become inelastic. This might be the origin. This threshold is not exposed in Codea so @John would have do some work to make it user settable or just set it to a lower value.
@piinthesky Thanks for the link. Lots of interesting info there.
@dave1707 just saw this video with a bunch of virus transmission simulations and it reminded me of your work
@Simeon - WOW (for the code) OMG - what have they let loose on us???
Thanks for posting, guess I won’t sleep for a while - lay back and ‘enjoy’ lockdown !!!
@Simeon That does look similar, but they put a lot more work into theirs.