Calculation of Reflection Angle

So, I'm writing somewhat of a 2D physics engine to simulate the movement of a ball. Part of that is to make sure that the ball bounces correctly when it collides with any line.

The speed of the ball is calculated through it's speed along the X- and Y-axis (xSpeed and ySpeed) of the coordinate system. When the ball collides with a line that goes only along one axis it's simple enough to just invert corresponding speed.* (For example, when colliding with a line running along the X-axis I set the ySpeed to -ySpeed)*.

However, I need a more general method to calculate the resulting X- and Y-speeds when the ball collides with a line running at any angle.

Note that I so far have been calculating any angles through "*arctan (ySpeed/xSpeed)*" for the direction of the ball, and as "*arctan "(y2-y1)/(x2-x1)*" (x1, y1, x2, y2 being the start and end points) for the angle of the lines.

**My question is therefore: How can I calculate resulting X and Y speeds after a collision?**

Please keep it on a somewhat simple level of mathematics if possible.