473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with generating parallel line

Hi,
Given a line segment L1 endpoints (x1, y1), (x2, y2), and distance D.
I want to generate a new line segment L2 such that L2 is parallel to
L1 and the distance between L1 and L2 is D.
Thank you.
Nov 13 '05 #1
8 7751
> Given a line segment L1 endpoints (x1, y1), (x2, y2), and distance D.
I want to generate a new line segment L2 such that L2 is parallel to
L1 and the distance between L1 and L2 is D.


Those 4 points you have define a slope for the line L1
m1 = (y2 - y1) / (x2 - x1);

The line L2 will have the same slope, I haven't thought this out too
carefully but I believe the only difference (in slope-intercept form) will
be the intercept, which can differ by D to distance the lines apart.

--
Jem Berkes
http://www.sysdesign.ca/
Nov 13 '05 #2


Jem Berkes wrote:
Given a line segment L1 endpoints (x1, y1), (x2, y2), and distance D.
I want to generate a new line segment L2 such that L2 is parallel to
L1 and the distance between L1 and L2 is D.


Those 4 points you have define a slope for the line L1
m1 = (y2 - y1) / (x2 - x1);


That's not a good idea. The slope may become infinite.

given
P1 ( x1, y1 )
P2 ( x2, y2 )
D

wanted
P3
P4

such that the distance from P3 to P1 equals D and
the distance from P4 to P2 equals D and
the line connecting P3 and P1 is perpendicular to the line P2 - P1 and
the line connection P4 and P2 is perpendiculat to the line P2 - P1 and
P3 and P4 or on the same side of the line P2 - P1

(make a drawing, all of the above are obvious from the drawing, but its
hard to describe and understand it in text form only)

Calulate:
P2 - P1, that is
dx = x2 - x1;
dy = y2 - y1;

a vector perpendicular to P2-P1 has the parameters

perp_x = dy
perp_y = -dx;

thus you just need to normalize this

len = sqrt( perp_x * perp_x + perp_y * perp_y );
perp_x /= len;
perp_y /= len;

and multiply with the desired distance

perp_x *= D;
perp_y *= D;

The points P3 and P4 are then:

P3 = P1 + perp

that is: x3 = x1 + perp_x
y3 = y1 + perp_y

P4 = P4 + perp

that is x4 = x2 + perp_x
y4 = y2 + perp_y
the line P4-P3 is parallel to P2-P1 with the given distance D

--
Karl Heinz Buchegger
kb******@gascad.at
Nov 13 '05 #3


Shamli wrote:

Hi,
Given a line segment L1 endpoints (x1, y1), (x2, y2), and distance D.
I want to generate a new line segment L2 such that L2 is parallel to
L1 and the distance between L1 and L2 is D.
Thank you.


Insufficient information to creeate a unique set (x3,y3), (x4,y4). There
are an infinite number of such pairs that produce a line parallel to L1
at a distance D from it.

For example, which do you want form the below drawings?
/ /
/ /
/ /

or

/
/ /
/ /
/
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
Nov 13 '05 #4
Shamli wrote:

Hi,
Given a line segment L1 endpoints (x1, y1), (x2, y2), and distance D.
I want to generate a new line segment L2 such that L2 is parallel to
L1 and the distance between L1 and L2 is D.
Thank you.


What is the topology of the surface?

/david

--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
Nov 13 '05 #5
Karl Heinz Buchegger wrote:

[snip]
given
P1 ( x1, y1 )
P2 ( x2, y2 )
D wanted
P3
P4 such that the distance from P3 to P1 equals D and
the distance from P4 to P2 equals D and
the line connecting P3 and P1 is perpendicular to the line P2 - P1 and
the line connection P4 and P2 is perpendiculat to the line P2 - P1 and


Why perpendicular? For example, a parallelogram with width D is a model
of the solution, but D is not necessarily the length a line segment
perpendicular to the sides.

/david

--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
Nov 13 '05 #6


David Rubin wrote:

Karl Heinz Buchegger wrote:

[snip]
given
P1 ( x1, y1 )
P2 ( x2, y2 )
D
wanted
P3
P4

such that the distance from P3 to P1 equals D and
the distance from P4 to P2 equals D and
the line connecting P3 and P1 is perpendicular to the line P2 - P1 and
the line connection P4 and P2 is perpendiculat to the line P2 - P1 and


Why perpendicular?


Because given a line segement, constructing another line segment which is
perpendicular to it, is trivial.
For example, a parallelogram with width D is a model
of the solution, but D is not necessarily the length a line segment
perpendicular to the sides.


True.
But if the sides are perpendicular to the base line and the line segments
have length D, then their endpoints P3/P4 form a line segment parallel to P2-P1
at the desired distance D.

The goal was to create a parallel line, how to do that is left to me :-)

--
Karl Heinz Buchegger
kb******@gascad.at
Nov 13 '05 #7


Karl Heinz Buchegger wrote:

David Rubin wrote:

Karl Heinz Buchegger wrote:

[snip]
given
P1 ( x1, y1 )
P2 ( x2, y2 )
D
wanted
P3
P4

such that the distance from P3 to P1 equals D and
the distance from P4 to P2 equals D and
the line connecting P3 and P1 is perpendicular to the line P2 - P1 and
the line connection P4 and P2 is perpendiculat to the line P2 - P1 and


Why perpendicular?


Because given a line segement, constructing another line segment which is
perpendicular to it, is trivial.


That is: in euclidian space :-)
For example, a parallelogram with width D is a model
of the solution, but D is not necessarily the length a line segment
perpendicular to the sides.


True.
But if the sides are perpendicular to the base line and the line segments
have length D, then their endpoints P3/P4 form a line segment parallel to P2-P1
at the desired distance D.

The goal was to create a parallel line, how to do that is left to me :-)


--
Karl Heinz Buchegger
kb******@gascad.at
Nov 13 '05 #8


David Rubin wrote:

Karl Heinz Buchegger wrote:

[snip]
given
P1 ( x1, y1 )
P2 ( x2, y2 )
D

wanted
P3
P4

such that the distance from P3 to P1 equals D and
the distance from P4 to P2 equals D and
the line connecting P3 and P1 is perpendicular to the line P2 - P1 and
the line connection P4 and P2 is perpendiculat to the line P2 - P1 and


Why perpendicular? For example, a parallelogram with width D is a model
of the solution,


Oops. Sorry.
I misread this sentence.
To answer: No, a general parallelogram is not a model of the solution.
I nail the inner angles down to 90 degrees (hence P3-P1 is perpendicular
to P2-P1) and thus create a rectangle.

--
Karl Heinz Buchegger
kb******@gascad.at
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan Lowe | last post by:
maybe its just me, but the behavior of parallel lists in for loops seems backwards. why doesnt it mirror parallel assignment? i think tuple-unpacking should take precedence, but instead iteration...
3
by: paytam | last post by:
Hi all, Is it possible to write parallel programming in C? I mean for example a simple program like I have a clock on a program that show me current time and and at the same time another job like...
11
by: lovecreatesbeauty | last post by:
For example, line L1 and line L2 are two lines in two-dimensional space, the start-points and end-points can be described with following the `point_t' type. The start-points and end-points are:...
2
by: Chris Smith | last post by:
Howdy, I'm a college student and for one of we are writing programs to numerically compute the parameters of antenna arrays. I decided to use Python to code up my programs. Up to now I haven't...
4
by: sesling | last post by:
I currently use an SQL command line that utilizes parallel threads. ex. select /*+ PARALLEL (ACCOUNT 20) */ Account_ID, Customer_Name, Add_Date from Customer_Info. By running this query using...
43
by: parallelpython | last post by:
Has anybody tried to run parallel python applications? It appears that if your application is computation-bound using 'thread' or 'threading' modules will not get you any speedup. That is because...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
16
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.