Parallel line calculations???

All about geometry

Parallel line calculations???

Postby LadyLisa » Wed Jul 01, 2015 11:49 pm

I have a set of lines where I know the beginning and end coordinates (X1, Y1, X2, Y2). What I need to calculate is a set of begin/end coordinates for parallel lines that makes the line a set distance away.

Example, if I have coordinates (0,0,50,0), which is a horizontal line, and the distance required is 10, then what I should end up with is (0,10,50,10) a line that is parallel to the first but offset by 10. I plan to put in +10 and -10 for the distances to get lines the same distance on either side.

How would I go about that?
LadyLisa
 
Posts: 1
Joined: Wed Jul 01, 2015 11:46 pm
Reputation: 0

Re: Parallel line calculations???

Postby Guest » Thu Jul 02, 2015 6:30 am

I assume you want the new parallel line perpendicularly offset by a set amount d.

Your line, with end points [tex](x_1, y_1)[/tex] and [tex](x_2, y_2)[/tex] has a gradient of
[tex]\frac{y_2-y_1}{x_2-x_1}[/tex]
which means to move in a parallel direction to the line we should offset our [tex]x[/tex] coordinate by some multiple, [tex]\lambda[/tex] say, of [tex]x_2-x_1[/tex] then offset our [tex]y[/tex] coordinate by [tex]\lambda (y_2-y_1)[/tex].
To move in a perpendicular direction we should offset our [tex]x[/tex] and [tex]y[/tex] coordinates by [tex]-\lambda(y_2-y_1)[/tex] and [tex]\lambda(x_2-x_1)[/tex] respectively.
See Figure 7 in Section 3 of http://www.mathcentre.ac.uk/resources/u ... 2009-1.pdf

What value should [tex]\lambda[/tex] be so that the total distance that has been offset is [tex]d[/tex]? We can use Pythagoras' theorem to tell us that.
[tex]d = \sqrt{(-\lambda(y_2-y_1))^2+(\lambda(x_2-x_1))^2}[/tex]
which rearranges to
[tex]d^2 = \lambda^2 (y_2-y_1)^2+\lambda^2 (x_2-x_1)^2[/tex]
[tex]d^2 = \lambda^2 ((y_2-y_1)^2+(x_2-x_1)^2)[/tex]
[tex]\lambda^2 = \frac{d^2}{(y_2-y_1)^2+(x_2-x_1)^2}[/tex]
[tex]\lambda = \pm\frac{d}{\sqrt{(y_2-y_1)^2+(x_2-x_1)^2}}[/tex]

Note that there are two solutions for [tex]\lambda[/tex] because there are two parallel lines that are at a distance of [tex]d[/tex] away from the original line.

We know know how much to offset by to get points in a perpendicular direction a distance of [tex]d[/tex] away.

So the new parallel line segment has end points:
[tex]\left(x_1-\lambda(y_2-y_1), y_1+\lambda(x_2-x_1)\right)[/tex] and [tex]\left(x_2-\lambda(y_2-y_1), y_2+\lambda(x_2-x_1)\right)[/tex]

where [tex]\lambda = \frac{d}{\sqrt{(y_2-y_1)^2+(x_2-x_1)^2}}[/tex] or [tex]\lambda = -\frac{d}{\sqrt{(y_2-y_1)^2+(x_2-x_1)^2}}[/tex].




Trying this out on your example: [tex]x_1=0,y_1=0,x_2=50,y_2=0,d=10[/tex] gives
[tex]\lambda = \pm\frac{10}{\sqrt{(0-0)^2+(50-0)^2}} = \pm\frac{1}{5}[/tex]

When [tex]\lambda = 1/5[/tex] the new parallel line segment has end points:
[tex]\left(0-(0-0)/5, 0+(50-0)/5\right) = \left(0, 10\right)[/tex] and [tex]\left(50-(0-0)/5, 0+(50-0)/5\right) = \left(50, 10\right)[/tex]

When [tex]\lambda = -1/5[/tex] the new parallel line segment has end points:
[tex]\left(0, -10\right)[/tex] and [tex]\left(50, -10\right)[/tex]

Which is consistent with what you asked for in the question,

Hope this helped,

R. Baber.
Guest
 


Return to Geometry



Who is online

Users browsing this forum: Google [Bot] and 2 guests