1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Intersect the circle with center $P$ and radius $d$ with the line. $\endgroup$ – Jack D'Aurizio Dec 20 '14 at 14:22
  • $\begingroup$ Hint: what are the coordinates $x$ and $y$ if the point is on the line? How to compute distance? Solve an equation. $\endgroup$ – Sigur Dec 20 '14 at 14:22
  • $\begingroup$ @JackD'Aurizio that is great idea but i have problem to implement this as a programming method. $\endgroup$ – m___b Dec 20 '14 at 14:27
0
$\begingroup$

From the equation $Ax+By+C = 0$, find the slope of the straight line: $$A\cdot{\Delta x} + B\cdot{\Delta y} = 0$$ As long as $B\ne 0$, $\Delta y = -\frac AB \Delta x$. Also it is known that $$d = \sqrt{(\Delta y)^2 + (\Delta x)^2} = \left|\Delta x\right| \sqrt{1+\frac {A^2}{B^2}}$$ So $\Delta y$ and $\Delta x$ can be solved (and there are two pairs of $\Delta x$ and $\Delta y$).

If $B=0$, the straight line is a vertical line and $\Delta y$ is pretty easy to solve; but using similar reasoning, $\Delta x = 0$ and then $$d = \sqrt{(\Delta y)^2 + (\Delta x)^2} = \left|\Delta y\right| \sqrt{1+0}$$

$\endgroup$
  • $\begingroup$ could you show me your idea on some example? I have some problem with understand yout equations $\endgroup$ – m___b Dec 20 '14 at 14:40
  • $\begingroup$ great, really thanks , i think only which solution is better , your or @Martin R $\endgroup$ – m___b Dec 20 '14 at 14:55
1
$\begingroup$

$(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 . $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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