Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 781361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:13:05+00:00 2026-05-14T20:13:05+00:00

I have x1,y1 and x2,y2 which forms a line segment. How can I get

  • 0

I have x1,y1 and x2,y2 which forms a line segment. How can I get another line x3,y3 – x4,y4 which is parallel to the first line as in the picture. I can simply add n to x1 and x2 to get a parallel line but it is not what i wanted. I want the lines to be as parallel in the picture.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:13:05+00:00Added an answer on May 14, 2026 at 8:13 pm

    What you want to do is to offset the coordinates in the orthogonal direction. If you know vector math, multiply the vector created by the distance between the endpoints of the line by the following matrix:

    [ 0 -1 ]
    [ 1  0 ]
    

    Say that the first line has the points (x1,y1), (x2,y2), with x=x2-x1, y=y2-y1.
    We also have L = sqrt(x*x+y*y), the length of the line (pardon the notation). Then the next line should be offset by

    [ 0 -1 ] [x]
    [ 1  0 ] [y]
    

    => dx = -y / L, dy = x / L
    which is the normalized offset for the new line.

    In C#-like pseudocode:

    var x1 = ..., x2 = ..., y1 = ..., y2 = ... // The original line
    var L = Math.Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
    
    var offsetPixels = 10.0
    
    // This is the second line
    var x1p = x1 + offsetPixels * (y2-y1) / L
    var x2p = x2 + offsetPixels * (y2-y1) / L
    var y1p = y1 + offsetPixels * (x1-x2) / L
    var y2p = y2 + offsetPixels * (x1-x2) / L
    
    g.MoveTo(x1p,y1p) // I don't remember if this is the way
    g.LineTo(x2p,y2p) // to draw a line in GDI+ but you get the idea
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.