Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the simplest sense (ignoring ball spin, friction, paddle movement, etc.) is to work out the angle of incidence relative to the surface normal and invert it. In the context of simple physics collisions, angle of incidence is the angle of movement of the ball relative to the normal of the surface of the paddle at the point of collision. In an arbitrary coordinate space the calculation is something like:</p> <pre><code>angleReflect = angleNormal - (angleBallMovement - angleNormal) </code></pre> <p>For a very simple case of a true rectangular paddle the normal is going to be perpendicular to the paddle's axis of motion. This gives you very little control over the ball, since the reflection angle is always going to be purely a function of the direction the ball is moving. </p> <p>You can simulate a curved paddle surface by varying the normal vector of the paddle's surface based on the distance from the center of the paddle that the ball impacts. This allows the player to change the ball's movement angle by intercepting the ball off center on the paddle to get a steeper or shallower reflection angle.</p> <p>The real fun is when you start adding friction, spin and paddle motion calculations to the mix. Gets a bit much for most players to keep track of, but allows for some interesting trick shots :)</p> <p>--</p> <p>As for <strong><em>how</em></strong> to calculate the angles, the trig function <code>Math.atan2(x, y)</code> will give you an angle (in radians) for a given [x,y] velocity vector, and <code>Math.sqrt(x*x + y*y)</code> gives you the length of the movement vector. This gives you a line that you can intersect with the surface of the paddle (factoring in the radius of the ball, if you're into accuracy) to get the point of impact. The remaining portion of the movement 'line' is reflected using the angle of incidence and whatever other calculations you add, giving a final position of the ball and new velocity vector.</p> <p>A laser pointer and a mirror are good visualization tools for this :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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