Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a circle centered at point $(x_1, y_1)$ and another point at $(x_2, y_2)$. This point, $(x_2, y_2)$ may or may not be within the radius ($r$) of the circle. I wanted to create a line going from the center of the circle $(x_1, y_1)$ to the point $(x_2, y_2)$. I have been using the quadratic formula to determine the intersection between this line and the radius of the circle. In my application, the point $(x_2, y_2)$ was always outside of the circle, so it made sense to always have a single intersection point along the radius of the circle. However, when $(x_2, y_2)$ is within the circle, I was not able to determine a point of intersection.

Is there a simple way to determine the closest point from $(x_2, y_2)$ to the circle's radius? If the line from $(x_1, y_1)$ were to extend forever, it would be the intersecting point of this extended line the circle's radius.

I am using the quadratic equation, but I am having troubles figuring out the intersection, without artificially extending the line. Is it also possible to determine the closest point from $(x_2, y_2)$ to the circle's radius if you don't know whether it is in or out of the radius? If wondering, I am using this in a coding environment.

I added my Inkscape drawing (editing with Paint it to show my application to match the question; please ignore the missing line and resulting gap from the circle).

Circle Intersection

Thank you.

share|improve this question
    
You must learn LaTeX markup! –  kjetil b halvorsen Mar 28 at 19:34
    
Thanks. I was not sure that it could be used here. –  baconcow Mar 29 at 17:05

1 Answer 1

I eventually found this answer here. Might be best to mark as duplicate, as this solution worked for me. Here is a summary of the solution as required within my application.

Point of intersection along the circumference of a circle centered at $(x_1, y_1)$ with a radius, $r$.

$x_{int} = x_1+\frac{r (x_2-x_1)}{\sqrt{(x_2-x_1)+(y_2-y_1)}}$

$y_{int} = y_1+\frac{r (y_2-y_1)}{\sqrt{(x_2-x_1)+(y_2-y_1)}}$

Where $(x_{int}, y_{int})$ is the point of intersection along the circumference of the circle with range $r$.

This apparently works for both scenarios where point $(x_2, y_2)$ is either within or outside of the radius of the circle.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.