# Find a point on line $AB$ such that it's distance from point $c = r$

I have a line $AB$ and a point $C$. I need to find point $D$ on line $AB$ at a distance $r$ from point $C$, how can I find point $D$? and is there a general formula to calculate this?

Coordinates of points $A, B, C$ are known.

• @Vikram sorry, i made a typo, i meant to write: how can i find point D – FrankK Oct 5 '17 at 7:38
• do you have the coordinates of A and B? – Vikram Oct 5 '17 at 7:40
• @Vikram yes, they are known – FrankK Oct 5 '17 at 7:42
• could you write this in an answer? – FrankK Oct 5 '17 at 7:46

First, you have to realize that there are three cases:

• Either the distance $r$ is inferior to the distance between $C$ and $AB$ and in that case you have no such point D

• Or the distance $r$ is equal to the distance between $C$ and $AB$. In that case you have one solution

• Or the $r$ is greater than the distance between $C$ and $AB$ and then you have two solutions

Already you can see that it looks that it will be like solving a polynomila of second degree.

Let's say $C(x_C,y_C)$ and $AB$ have the following equation $y=ax+b$.

Then $D(x_D,y_D)$, being on $AB$, follows $y_D=ax_D+b$ (equation 1)

Distance $CD$ is $CD=\sqrt{(x_C-x_D)^2+(y_C-y_D)^2}=r$ (equation 2)

Or $(x_C-x_D)^2+(y_C-y_D)^2=r^2$

$(x_C-x_D)^2+(y_C-ax_D-b)^2=r^2$ (after using equation 1) which is a quadratic equation for $x_D$...

I think you can take it from here