views:

256

answers:

1

Using the following start and end point coordinate values of a baseline:

X1 = 5296823.36 Y1 = 2542131.23

X2 = 5311334.21 Y2 = 2548768.66

I would like to calculate the start and end coordinates of a pendicular line that intersects the baseline at the mid-point. This intersecting, perpendicular line should extend at a given distance either side of the baseline (e.g. Dist=100).

I would be very grateful if anyone could provide some guidance using simple formulas that can be tranferred to Excel or VB.

Many thanks in advance.

+2  A: 

Steps to do:

Find the midpoint of the two coordinates (xmid, ymid)

Find the gradient of the line segment joining the two coordinates (call it m).

The gradient of a line perpendicular to this line is -1/m.

Use this new gradient and the coordinates of the midpoint (xmid, ymid) to find the equation of the perpendicular line (substitute xmid, ymid and -1/m into the equation of a line), call it y = -1x/m + k

Imagine a right angled triangle from xmid, ymid to your target point (r units along the perpendicular line is the hypotenuse). The x component will be X units across, the y component will be (-1X/m + k) units up.

Solve

r^2 = X^2 + (-1X/m + k)^2

to find X. Where you have already found r, m and k in the previous steps.

Substitute the +ve and -ve values of this into y = -1x/m + k to get the y coordinates of your endpoints, and Bob's your Uncle.

It should be relatively straight forward to translate this into any given programming language in a very short space of time but you may need to understand the underlying maths to do so, and as a Maths teacher I'm not going to do your Homework for you.

Amos