Intersection between circle and segment that starts in middle of circle

36 Views Asked by At

Let $C$ be a circle with center $(c_x,c_y)$ and radius $r$

Let $s$ be a segment that starts in $(c_x,c_y)$ and ends in a point $(x, y)$ outside $C$

How can I find the point $P=(p_x,p_y)$ where $s$ intersects $C$ ?

I thought about writing the line equation from $(c_x,c_y)$ and $(x, y)$, than find the intersection of $s$ and $C$, and from the $2$ results, apply some filter to get the result I expect, but I wonder if there is a way more straightforward than that.

1

There are 1 best solutions below

2
On BEST ANSWER

As the segment starts in the centre of the circle, let $$d=\sqrt{(x-c_x)^2+(y-c_y)^2}>r$$ Your point is $$P=(c_x,c_y)+\frac{r}{d}(x-c_x,y-c_y)$$ You can see this is the point on the segment at distance $r$ from the centre.