intersection of a line (certain direction) and a circle

36 Views Asked by At

I need to calculate (previously) the point where a ball will touch the inside of a circle (for a game I'm developing). So I have two equations, one of the direction of the ball, and another of the circle (with variables related screen resolution of my game):

$$(x - W)^2 + (Y - H)^2 = r^2$$

$$Y = T(X - X_p) + Y_p$$

where: W = Screen weight / 2

H = Screen height / 2

Xp and Yp = Position of the ball

T = tangent of Direction D

I also did the equations this site: https://www.desmos.com/calculator/uupif7b2j9

I tried to calculate the system of equations, reaching an equation of 2nd degree, but when I resolve, not the result I expected.

sorry for my English

1

There are 1 best solutions below

1
On

I am not sure if I understood correctly: line goes through center of a circle and you need intersection points of line and circle?

On your picture it looks like that. But line equation doesn't confirm this.