[Math] Find point on line withv given start point, distance, and line equation

geometry

I have line equation $$ Ax +By + C = 0.$$

I have start point (on this line): $ P_0 = (X_0, Y_0)$.
I have distance $d$ too.

I need find point $P_2$ with distance $d$ from $P_0$ and placed on this line. I know that we have 2 points with this distance. But how calculate? I need some programmatic solution.

Best Answer

$(A, B)$ is a normal vector for the line, therefore $v = (-B, A)$ is a direction vector and you get all points on the line with

$$ (x, y) = P_0 + t \, v = (X_0, Y_0) + t (-B, A), \quad t \in \mathbb R. $$

Now choose $t$ such that the length of $t(−B,A)$ is equal to the given distance $d$, this gives the two points

$$ (X_2, Y_2) = (X_0, Y_0) \pm \frac d{\sqrt { A^2 + B^2}} (-B, A) \quad . $$

Related Question