title: How do I bounce a point off of a line?
body: <p>I'm working on writing a Pong game and I've run across a problem. </p>
  
  <p>I'm trying to figure out how to bounce a point off of a line. </p>
  
  <p>The best method I can figure out to do this with is</p>
  
  <ul>
  <li>Calculate the current and future position of the Ball.
  
  <ul>
  <li>Line Segment: {Ball.location,  Ball.location + Ball.direction} (Ball.location and Ball.direction use a custom vector/coordinate class)</li>
  </ul></li>
  <li>Calculate if the generated line segment intersects with any of the walls or paddles.
  
  <ul>
  <li>??? Don't know how to do this yet (Will ask in a separate question)</li>
  </ul></li>
  <li>At the first intersection found
  
  <ul>
  <li>Bounce the ball off of the line
  
  <ul>
  <li>Create a triangle formed with
  
  <ul>
  <li>a = Ball's current position</li>
  <li>b = Intersection point of the line.</li>
  <li>c = Closest point to the Ball's current position on the line.</li>
  </ul></li>
  <li>Find the angle that the ball hits the line
  
  <ul>
  <li>angle = cos(distance(b, c) / distance(a, b))</li>
  </ul></li>
  <li>Find the angle to rotate the ball's direction
  
  <ul>
  <li>(90 - angle)*2</li>
  </ul></li>
  <li>Rotate Ball's direction and move it to it's new position
  
  <ul>
  <li>ignoring distance traveled to hit the line for now, doesn't need to be exactly on the line</li>
  </ul></li>
  </ul></li>
  </ul></li>
  <li>Else if there is no intersection
  
  <ul>
  <li>Move the ball to it's new position.</li>
  </ul></li>
  </ul>
  
  <p>Is this an acceptable method or am I missing something?</p>