Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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:
Say that the first line has the points
(x1,y1),(x2,y2), withx=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=>
dx = -y / L,dy = x / Lwhich is the normalized offset for the new line.
In C#-like pseudocode: