Parallel line calculations???

Oddgamer

New member
Joined
Jun 25, 2015
Messages
12
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?
 
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?

You know to calculate the slope of the given line [tan(Θ)] passing through (x1,y1) and (x2,y2) → Calculate cos(Θ)

You know to calculate the y-intercept of the line (b)

The y-intercepts (b1) of those off-set lines would be b1 = 10 ± b/cos(Θ)

You know the slopes of those off-set lines → calculate the x-intercepts.

If you are still stuck - come back (showing work)....
 
X,Y
850,850
1113,1658


Line: 850,850 -> 1113,1658
x-: 1113-850 = 263
y-: 1658-850 = 808
O = 808/263 (slope)
cos(O) = 0.99856275136405952261570426940543


y-intercept:
y = mx+b
850 = (808/263)850+b
b = 850 - (808/263)850
b = -1761.4068441064638783269961977186


That's b0. b1 and b2 would, then, be:
b1 = 10 + b/cos(O) = -1753.9420674367653949613517687665
b2 = 10 - b/cos(O) = 1773.9420674367653949613517687665


.... That's not looking right to me...


(808/263)x + -1753.9420674367653949613517687665 = 0
x = 570.89946006914517187479642968514


(808/263)x + 1773.9420674367653949613517687665 = 0
x = -577.40936105924418177578652869504


... Sooo, I'm assuming I'm way off here somewhere...
 
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?
A slightly different way if y1 is not equal to y2: Given (x1, y1) and (x2, y2) the line L1 going through those are
L1: y = y1 + s (x-x1)
The line L2 perpendicular to that is
L2: y = y1 - (x-x1) / s
Now let (x3, y3) be a point 10 units away from (x1,y1) on line L2, i.e.
(x3-x1)2 + (y3-y1)2 = 100
AND
y3 = y1 - (x3-x1) / s
Then the line L3 going through (x3,y3) with the same slope as L1 is ...
 
X,Y
850,850
1113,1658


Line: 850,850 -> 1113,1658
x-: 1113-850 = 263
y-: 1658-850 = 808
O = 808/263 (slope)
cos(O) = 0.99856275136405952261570426940543

This part here is wrong. The slope of the line is indeed 808/263. However, the slope is not theta. The slope is the tangent of theta. So, if tan(theta) = 808/263, then what is cos(theta)? Draw a triangle if necessary...
 
tan(Θ) = 808/263 → cos(Θ) = 263/√(8082 + 2632)
 
X,Y
850,850
1113,1658




Line: 850,850 -> 1113,1658
x-: 1113-850 = 263
y-: 1658-850 = 808
Slope = 808/263 (thanks ksdhart)
Slope = 3.0722433460076045627376425855513
cos(O) = 0.000364249279465066001138452120609 (thanks Subhotosh Khan)


y-intercept:
y = mx+b
850 = (808/263)850+b
b = 850 - (808/263)850
b = -1761.4068441064638783269961977186


That's b0. b1 and b2 would, then, be:
b1 = 10 + b/cos(O) = -4835718.1287860168572626465613207
b2 = 10 - b/cos(O) = 4835718.1287860168572626465613207


.... And that's not looking right to me again...




Checking with Ishuda:
L1: 1658 = 850 + 3.07(1113-850)
L2: 1658 = 850 - (1113-850)/3.07


(x3-x1)^2 + (y3-y1)^2 = 100
y3 = y1 - (x3-x1) / s
So... a = x3, b= x1, c = y3, d = y1, e = s (for now).
(a-b)^2 + (c-d)^2 = 100
c = d - (a-b) / e


Sub in c:
(a-b)^2 + (c-d)^2 = 100 (this is w^2)
c = d - (a-b) / e
(a-b)^2 + ((d - (a-b) / e)-d)^2 = w^2

[EDIT!! There's a big problem with trying to use e as a variable!!! I feel stupid.]
Solve for a:
a = (1+2be^2 +- sqrt(1+4w^2e^4)) /2e^2
b = 850 (x1)
d ... vanishes
e = 3.07 (slope)
w = 10
a = (1+2(850)(3.07)^2 +- * sqrt(1+4(10)^2(3.07)^4))/2(3.07)^2)
a = (16023.33 +- 188.50)/18.8498
a = 860.03 or 840.05

a is x3, so back above y3 = y1 - (x3-x1) / s
y3 = 850 - (860-850)/3.07 = 846.7
OR
y3 = 850 - (840-850)/3.07 = 853.2

Though now I'm confused about which one I use (if it even matters... or do those two points define the line like x1,y1 and x2,y2??)
 
Last edited:
Top