# Is there an algorithm that causes a straight line and a circle to collide and bounce?

I used a vector to determine the collision between a line and a circle. Here's the way I thought of it in the beginning.

1. When the ball collides with a straight line, it finds a normal line passing through the center point.

2. Take the coordinates before the ball collides and move symmetrically with respect to the normal.

The results were similar to those intended, but unstable. Since then, I have tried to find the angle using the vector, but it has not progressed since then.

Find the intersection point between the parallel to the line at distance R and the trajectory of the center of the ball.

Now notice that the sum of the incoming and outgoing direction vectors (let I and O) is parallel to the line, corresponding to a vector α.D of unknown length.

I + O = α.D


The by expressing that I and O have the same length,

(α.D - I)² = I²


and

α.D² = 2 D.I


which gives α and O = 2 (D.I/D²).D - I.

• If D is a unit vector, I understand.
– GT K
Commented Oct 19, 2022 at 1:25
• If so, will it be solved if i find the unit vector of the straight line?
– GT K
Commented Oct 19, 2022 at 2:14
• @GTK: D does not need to be unit. The O solution is a vector of the same length as I.
– user16034
Commented Oct 19, 2022 at 6:55