# Thread: finding the "end points" of an orthogonal line giving the lenght

1. ## finding the "end points" of an orthogonal line giving the lenght

First of all sorry if am posting on the wrong sub forum or the title is a little misleading..

Am working on a software right now, and am really embarrassed that I dont remember the basic mathematic to solve this problem.

this is the thing, for any given line (lets say L1) I need to create two orthogonal lines (L2 and L3) with length C, at the two ends of L1

What I have is P1, P2 and C, and what I need is P3(x3, y3), P4(x4, y4) etc

2. Hello, axl456!

This takes quite a bit of work . . .

$\text{For any given line }L_1\text{, I need to create two orthogonal lines}$
$L_2\text{ and }L_3\text{ with length }c\text{ at the ends of }L_1.$

We have points $P_1(x_1,y_1)$ and $P_2(x_2,y_2).$

Let: $\,\theta$ = the angle at $\,P_1.$

Let: $R \:=\:\overline{P_1P_2} \:=\:\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$

Code:

|
|                    (x2,y2)
|                       ♥ P2
|             R     *   |
|               *       | y2-y1
|           *  @        |
|    P1 ♥---------------*
|    (x1,y1)  x2-x1
|
- - + - - - - - - - - - - - - - - -
|


Then we have: . $\begin{Bmatrix}\sin\theta &=& \dfrac{y_2-y_1}{R} \\ \\[-4mm] \cos\theta &=& \dfrac{x_2-x_1}{R}\end{Bmatrix}$

Let:. . $\begin{Bmatrix} \Delta x &=& \frac{1}{2}c\sin\theta \\ \\[-4mm] \Delta y &=& \frac{1}{2}c\cos\theta \end{Bmatrix}$

Code:

|                   C
|                   *
|                   |\
|                   | \
|   A               |  \  ∆x
|   *               .---♥---.
|   |\              *  P2\  |
| ∆y| \         *         \ | ∆y
|   |  \P1  *              \|
|   .---♥---.               *
|     ∆x \  |               D
|         \ |
|          \|
|           *
|           B
|
- - + - - - - - - - - - - - - - - -
|

To move from $\,P_1$ to $\,A$: .move left $\Delta x$ and up $\Delta y.$
. . Hence: . $A(x_1\! -\! \Delta x,\;y_1 \!+\! \Delta y)$

To move from $\,P_1$ to $\,B$: .move right $\Delta x$ and down $\Delta y.$
. . Hence: . $B(x_1\! +\! \Delta x,\;y_1\!-\!\Delta y)$

To move from $\,P_2$ to $\,C$: .move left $\Delta x$ and up $\Delta y.$
. . Hence: . $C(x_2\!-\!\Delta x,\;y_2\!+\!\Delta y)$

To move from $\,P_2$ to $\,D$: .move right $\Delta x$ and down $\Delta y.$
. . Hence: . $D(x_2\!+\!\Delta x,\;y_2\!-\!\Delta y)$

While waiting for a reply, I keep analyzing it and found another solution..

what I did is simple use the slope and distance equation:

$D \:=\:\sqrt{(x-x0)^2 + (y-yo)^2}$

$m = (y-y0)/(x-x0)$

being (x, y) the point I need, and (x0, y0) the points I have.
From those two I got this equation:

$x^2 - 2xx0 + xo^2 -(\dfrac{d^2}{1 + m^2}) = 0$

I solve it with the quadratic formula, and got 2 results (the two equidistant points that form the new line)

this is the result:

Again thank you!..