<![CDATA[Why do colliding blocks calculate PI ? when m2 = 1,100,10000, collisioncounter = 3, 31, 314, etc ?]]> false false true true false ]]> ./collidingblockscomputepi/Screenshot 2024-06-18 at 9.31.24 AM.png ./1authorlookangphoto5050.png;./01authorPacoEsquembre2011.png;./01authorFelix_J_Garcia_Clemente.png 20 1 false VARIABLE_EDITOR Var Table true false VARIABLE_EDITOR layout true false VARIABLE_EDITOR chat true false CODE_EDITOR Decoration true false ODE_EDITOR Evol Page true false EVENT_EDITOR Event true false CROSSING_EVENT BISECTION 100 true 0) { return false; // no collision } var impulse = -(1 + e) * velocityAlongNormal; impulse = impulse / (1 / ball1.mass + 1 / ball2.mass); var impulseV = { x: impulse * normal.x, y: impulse * normal.y } ball1.velocity.x -= 1 / ball1.mass * impulseV.x; ball1.velocity.y -= 1 / ball1.mass * impulseV.y; ball2.velocity.x += 1 / ball2.mass * impulseV.x; ball2.velocity.y += 1 / ball2.mass * impulseV.y; collisionCounter = collisionCounter + 1 //_pause() ]]> EVENT_EDITOR wallleft1 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR wallleft2 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR wallright1 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR wallright1 2 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR walltop1 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR walltop1 2 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR walbottom1 false false CROSSING_EVENT BISECTION 100 true EVENT_EDITOR walbottom1 2 false false CROSSING_EVENT BISECTION 100 true t dt ball1.velocity.x ball2.velocity.x ball1.velocity.y ball2.velocity.y RungeKutta 10000 0.00001 false false false false CODE_EDITOR FixRel Page true false 0)){ ball1x = ball1.x = -ball1.radius + canvas.width/2 ball1.velocity.x = -e * ball1.velocity.x; collisionCounter = collisionCounter + 1 // only need these 2 lines for ball1 collisiion with the left wall } if ((ball2.x - ball2.radius + canvas.width/2<0)){ ball2x = ball2.x = ball2.radius - canvas.width/2 ball2.velocity.x = -e * ball2.velocity.x; collisionCounter = collisionCounter + 1 } if ((ball2.x + ball2.radius - canvas.width/2>0)){ ball2x = ball2.x = -ball2.radius + canvas.width/2 console.log("hit") ball2.velocity.x = -e * ball2.velocity.x; collisionCounter = collisionCounter + 1 } if ((ball1.y - ball1.radius + canvas.height/2<0)){ ball1y = ball1.y = ball1.radius - canvas.height/2 ball1.velocity.y = -e * ball1.velocity.y; collisionCounter = collisionCounter + 1 } if ((ball1.y + ball1.radius - canvas.height/2>0)){ ball1y = ball1.y = -ball1.radius + canvas.height/2 ball1.velocity.y = -e * ball1.velocity.y; collisionCounter = collisionCounter + 1 } if ((ball2.y - ball2.radius + canvas.height/2<0)){ ball2y = ball2.y = ball2.radius - canvas.height/2 ball2.velocity.y = -e * ball2.velocity.y; collisionCounter = collisionCounter + 1 } if ((ball2.y + ball2.radius - canvas.height/2>0)){ ball2y = ball2.y = -ball2.radius + canvas.height/2 ball2.velocity.y = -e * ball2.velocity.y; collisionCounter = collisionCounter + 1 } // to prevent accidental overlap of balls //sync ejss variables to chatgpt's ball1.x = ball1x ball1.y = ball1y ball2.x = ball2x ball2.y = ball2y // prevent overlap ball 1 overlap ball2 var dx = ball1.x - ball2.x; var dy = ball1.y - ball2.y; var distance = Math.sqrt(dx * dx + dy * dy); var tol = 1.001 var tol2 = tol *1.0001 if (distance < ball1.radius*tol + ball2.radius*tol ) { var angle = Math.atan2(dy, dx); console.log (angle) var targetX = ball2x + Math.cos(angle) * (ball1.radius + ball2.radius)*tol2; var targetY = ball2y + Math.sin(angle) * (ball1.radius + ball2.radius)*tol2; ball1x = ball1.x = targetX; ball1y = ball1.y = targetY; } /* // prevent overlap ball 2 overlap ball 1 when Evolution is running var dx = ball1.x - ball2.x; var dy = ball1.y - ball2.y; var distance = Math.sqrt(dx * dx + dy * dy); var tol = 1.001 var tol2 = tol *1.0001 if (distance < ball1.radius*tol + ball2.radius*tol ) { var angle = Math.atan2(dy, dx); console.log (angle) var targetX = ball1x - Math.cos(angle) * (ball1.radius + ball2.radius)*tol2; var targetY = ball1y - Math.sin(angle) * (ball1.radius + ball2.radius)*tol2; ball2x = ball2.x = targetX; ball2y = ball2.y = targetY; } */ ]]> CODE_EDITOR ke true false LIBRARY_EDITOR fullscreen true false LIBRARY_EDITOR changeOrientation true false LIBRARY_EDITOR speech true false { // console.log(voice.name, voice.lang) //}) //debug // Queue this utterance. window.speechSynthesis.speak(msg); } ]]> LIBRARY_EDITOR checkCollision true false LIBRARY_EDITOR evolveCollision true false 0) { return false; // no collision } var impulse = -(1 + e) * velocityAlongNormal; impulse = impulse / (1 / ball1.mass + 1 / ball2.mass); var impulseV = { x: impulse * normal.x, y: impulse * normal.y } ball1.velocity.x -= 1 / ball1.mass * impulseV.x; ball1.velocity.y -= 1 / ball1.mass * impulseV.y; ball2.velocity.x += 1 / ball2.mass * impulseV.x; ball2.velocity.y += 1 / ball2.mass * impulseV.y; return {ball1: ball1, ball2: ball2}; } // else no collision return false; } /* more output from ChatGPT In this example, ball1 and ball2 are objects with properties including x, y, radius, color, mass and velocity properties that represent the position, radius, color, mass, and velocity of the balls. The function uses the checkCollision() function to check for a collision and, when collision is detected, it updates the velocity of the balls according to the physics equations and the coefficient of restitution (e). The coefficient of restitution represents the elasticity of collision, value of 'e' ranges from 0 to 1, means 0 means the collision is completely inelastic and 1 means it is completely elastic. You can call this function in your main code and test with 2 balls positions, radius and coefficient of restitution, here is an example more code of which i combine into the EJSS variables var ball1 = {x: 5, y: 5, radius: 10, color: "red", mass:2, velocity:{x:5, y:3}}; var ball2 = {x: 10, y: 15, radius: 5, color: "green", mass:3, velocity:{x:7, y:4}}; var newVelocities = evolveCollision(ball1, ball2, 0.8); if(newVelocities){ console.log(newVelocities); } */ ]]> LIBRARY_EDITOR kineticEnergy true false HTML_VIEW_EDITOR HtmlView Page true false 0 0 0 800 600 true true Elements.Panel true Elements.Panel false Elements.Panel false Elements.Panel Elements.Label Elements.Slider Elements.Label Elements.Slider Elements.Label Elements.Slider false Elements.Panel Elements.Label Elements.ParsedField Elements.Label Elements.ComboBox 0)? opts[0]:""; // selected option //["1","100","10000","1000000"] if (option == "1"){ ball2mass = option ball2.mass = option } alert(opts) //_update() ]]> Elements.Slider Elements.Label Elements.Slider Elements.Label Elements.Slider Elements.Label Elements.Slider Elements.TwoStateButton Elements.Button Elements.Button false Elements.Panel false Elements.PlottingPanel Elements.Shape2D Elements.Shape2D Elements.Shape2D 0)) { ball1x = ball1.x = -ball1.radius + canvas.width/2 //ball1.velocity.x = -e * ball1.velocity.x; } if ((ball1.y - ball1.radius + canvas.height/2<0)) { ball1y =ball1.y = ball1.radius - canvas.height/2 //ball1.velocity.x = -e * ball1.velocity.x; } if ((ball1.y + ball1.radius - canvas.height/2>0)) { ball1y = ball1.y = -ball1.radius + canvas.height/2 //ball1.velocity.x = -e * ball1.velocity.x; } // prevent overlap 2 balls var dx = ball1.x - ball2.x; var dy = ball1.y - ball2.y; var distance = Math.sqrt(dx * dx + dy * dy); var tol = 1.001 var tol2 = tol *1.0001 if (distance < ball1.radius*tol + ball2.radius*tol ) { var angle = Math.atan2(dy, dx); console.log (angle) var targetX = ball2x + Math.cos(angle) * (ball1.radius + ball2.radius)*tol2; var targetY = ball2y + Math.sin(angle) * (ball1.radius + ball2.radius)*tol2; ball1x = ball1.x = targetX; ball1y = ball1.y = targetY; } //ball1.x= ball1x //ball1.y= ball1y var offset = { x: 0, y:0 } ; offset.x = ball1xnew - ball1.x; offset.y = ball1ynew - ball1.y; //var toffset = t var dt = tnew - t if (dt==0) { ball1.velocity.x =0 ball1.velocity.y =0 } else { ball1.velocity.x =(offset.x)/(dt) ball1.velocity.y =(offset.y)/(dt) } ]]> Elements.Shape2D 0)) { ball2x = ball2.x = -ball2.radius + canvas.width/2 //ball1.velocity.x = -e * ball1.velocity.x; } if ((ball2.y - ball2.radius + canvas.height/2<0)) { ball2y =ball2.y = ball2.radius - canvas.height/2 //ball1.velocity.x = -e * ball1.velocity.x; } if ((ball2.y + ball2.radius - canvas.height/2>0)) { ball2y = ball2.y = -ball2.radius + canvas.height/2 //ball1.velocity.x = -e * ball1.velocity.x; } // prevent overlap 2 balls var dx = ball1.x - ball2.x; var dy = ball1.y - ball2.y; var distance = Math.sqrt(dx * dx + dy * dy); var tol = 1.001 var tol2 = tol *1.0001 if (distance < ball1.radius*tol + ball2.radius*tol ) { var angle = Math.atan2(dy, dx); console.log (angle) var targetX = ball1x - Math.cos(angle) * (ball1.radius + ball2.radius)*tol2; var targetY = ball1y - Math.sin(angle) * (ball1.radius + ball2.radius)*tol2; ball2x = ball2.x = targetX; ball2y = ball2.y = targetY; } ball2.x= ball2x ball2.y= ball2y var offset = {x: 0, y:0}; offset.x = ball2xnew - ball2.x; offset.y = ball2ynew - ball2.y; //var toffset = t var dt = tnew - t if (dt==0){ ball2.velocity.x =0 ball2.velocity.y =0 } else { ball2.velocity.x =(offset.x)/(dt) ball2.velocity.y =(offset.y)/(dt) } ]]> Elements.Panel "pi-collision problem"

"digit dynamics," tends to be around 314. This intriguing result is related to the mathematical constant π (pi).

The setup involves two blocks of significantly different masses (here, 1 kg and 10000 kg) sliding on a frictionless surface. One block starts moving towards the other, and they collide elastically. The number of collisions before they come to rest or one block moves away is proportional to the digits of π.

For two blocks with masses in the ratio 1:100n, the number of collisions will be approximately equal to the first n+1 digits of π. In this case, with n = 3 (since 10000 = 1002), the number of collisions is close to the first 3 digits of π, which is 314.

This remarkable connection arises from the way the collisions and velocities behave, involving iterative calculations that mimic the series expansion of π.

How to get to 1000000 kg? and collisionCounter = 3141 ?

Since this is a computationally intensive during the collisions between left wall and 2 balls, perhaps slowing down the velocities of ball2 in x direction to -0.0001 might allow to compute the correct number of collisions before it becomes unstable? Good luck! and let me know if it works! Enjoy!

]]>