# Find coordinate of a point

I have two points, $P_1$ and $P_2$ as well as a line $Y$. I'm trying to find the $X$ point at which a line, dropped from the midpoint of $P_1P_2$ will hit the line $Y$.

-
 What have you tried? – Gabe Apr 26 '12 at 16:51

## migrated from stackoverflow.comApr 26 '12 at 16:55

Given that (I assume) you know the gradient of line P1P2 (if you know the co-ordinates of P1 and P2), you implicitly know the gradient of the line perpendicular to it. You therefore have the gradient and 1 point of that line, and you know the y-axis value of the other point. Plugging all that info into y=mx+c will get you your answer :)

-
How do I get the gradient of a perpendicular line? – cwolves Apr 26 '12 at 16:57
@cwolves: it's the negative of the reciprocal of the original line's gradient. – J. M. Apr 26 '12 at 17:00
@J.M. - thanks :) – cwolves Apr 26 '12 at 17:00
It's the value of your line divided by -1 – ChrisW Apr 26 '12 at 17:01

A solution using dot products:

Let $P_m = (p_{m1}, p_{m2})$ be the midpoint of $P_1 = (p_{11}, p_{12})$ and $P_2 = (p_{21}, p_{22})$. Then the point $X$ is such that the vector $P_m X$ has

1) $(P_m X) \cdot (P_1 P_2) = 0$ because the vectors are perpendicular,

2) $X = (x_1, x_2) = (x_1, Y)$ where Y is known.

Plugging in:

$$(P_m X) \cdot (P_1 P_2) = 0 = (x_1 - p_{m1}, Y - p_{m2}) \cdot (p_{21} - p_{11}, p_{22} - p_{12})$$

$$=(x_1 - p_{m1})(p_{21}-p_{11}) + (Y-p_{m2})(p_{22}-p_{12})$$

Rearranging for $x_1$,

$$x_1 = p_{m1} + \frac{(Y-p_{m2})(p_{22}-p_{12})}{(p_{11}-p_{21})}$$

-

You know co-ordinates of P1 and P2 as (x1, y1) and (x2, y2). You can find slope of that line using m = [y1 - y2] / [x1 - x2]

The slope of perpendicular line is found by reciprocal of negative of slope. -(1/m)

and the mid point can be found using Mid Point formula. Then use point slope y=mx+ c

-

With the coordinates of $P_1$ and $P_2$, you can compute the slope of the line containing a segment $\overline{P_1P_2}$

Say that after computing the slope of $\overline{P_1P_2}$, you find out that it is $m$

If you remember High-School Geometry (This is one of those problems you probably did in High School too!) if two lines in $\mathbb{R^2}$ are perpendicular, the slopes of these two lines are negative reciprocal of each other.
Note: $\mathbb{R^2}$ is basically a mathy way of denoting a $2$-Dimensional Space. The following relation doesn't work in $\mathbb{R^3}$ or any other higher dimensional (vector) space

If $m'$ be the slope of your perpendicular line, $$m=-\frac1{m}$$

From this relation, you have the slope of the perpendicular line.

With this figured out, all you now need to do is use the "Point-slope formula" to find out the equation of the perpendicular line.

The "Point-slope formula" goes something like this: $$m(x-x_1)=(y-y_1)$$ Where $m$ is the slope of the line ($-\frac1{m}$ in this case) and $(x_1,y_1)$ is any point on the line. (The mid-point of $\overline{P_1P_2}$ in this case).

Now with the equation of the perpendicular figured out, you need to find the intersection between the perpendicular and line $Y$. To do this, you solve the two equations.

On solving the two equations, you should get a value for $x$ and $y$. This is the point where your perpendicular "hits" your line $Y$.

Hope it Helps!

-