# Co-ordinates of parallel line segments.

This topic is 3376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, Working in 2d. I have a line segment made up of two vectors, one for each end-point. using these vectors I wish to create another line segment parallel to it. Example 0,0 ----------------- 1, 0 x,y ----------------- x,y The space between these lines is say 5. How do I find the co-ordinates of the new line? I need a formula that will work for line segments at all angles. Is there a good c lib for performing calculations like this? Thanks for your time. Jayson.

##### Share on other sites
Get a 'normal' to the line, which is a direction perpendicular to it, and offset the points in that direction to create the new line.

// End-pointsvec2d start;vec2d end;// Calculate the normalvec2d normal;normal.x = start.y - end.y;normal.y = end.x - start.x;normalize(normal);// Create new end-pointsvec2d newStart = start + normal * distance;vec2d newEnd = end + normal * distance;

##### Share on other sites
Perfect, thank you very much. :)

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 13
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009404
• ### Who's Online (See full list)

There are no registered users currently online

×