Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The whole point of Newtonian physics is that it is <em>not</em> random, it is <em>deterministic</em>. If you throw the same ball against the same wall at the same angle and with the same velocity and the same spin, it goes to the same place every time. </p> <p>This sort of program is a really great learning opportunity for both programming and physics. What I encourage you to do is to first write a program that simulates very simple bouncing. As you note, when an object is moving straight down and hits a horizontal surface, then you can model the bounce as simply reversing the vertical velocity component. Just get that right; no gravity, no nothing. That's a great start. </p> <p>Then try adding bouncing off of horizontal walls, the same way.</p> <p>Then try adding bouncing off of walls that are <em>not</em> aligned with horizontal or vertical directions. That's where you're going to have to learn how vectors and trigonometry work, because you'll have to work out what component of the ball's velocity is changed by striking the wall obliquely.</p> <p>Then add gravity. Then add friction from the air. Then add the fact that the ball can be spinning. Add elasticity, so that you can model deformation of the ball. </p> <p>Once you get to that point, if you want to introduce randomness you'll be able to figure out how to do it. For example, you might introduce randomness by saying "well, when the ball strikes the wall and deforms, I'll introduce a random element that changes its deformation by 0-10%". That will then change how the simulation bounces the ball. You can experiment with different kinds of randomness: add random air currents, for instance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload