   2D - how to get a parallel line with an orthogonal distance?
  Hi at all!thx for answering my previous questions.No I got a simple problem. I want to draw aparallel line with an orthogonal distance in 2D space.here is a picture for an example:http://dubtissm.cabspace.com/img/code/line.gifSo I know I could calculate the angle of the given line from the horizon, add 90° to the angle, andget the point above P1 via x=sin(angle+90)*distance+P1.xy=cos(angle+90)*distance+P1.yBut for calculating the angle of the given line,I need the acos or asin function.These are missing on my platform.Hopefully someone could help me ;)   
  An easy solution would be to use vectors.1. Calculate the vector between the two endpoints of the line: v1 = p1-p02. Calculate an orthogonal vector by exchanging the x and y value and negate one component3. Normalize the orthogonal vector4. Multiply it with your distance and add it to both enpoints to get the endpoints of your new lineExample:P1(2,2), P2(10,6), dist = 2V1 = P2 - P1 = (8,4)Orthogonal vector V2 = (-4,8) or V2 = (4,-8) depending on your offset directionNormalize V2 = (-4,8)/len(V2) = (-4,8)/sqrt(-4²+8²) = (-4,8)/8.94 = (-0.45,0.89)P1' = P1 + V2 * dist = (2,2) + (-0.9,1.78) = (1.1,3.78)P2' likewise[Edited by - Quak on October 18, 2006 12:04:05 PM];Quote:Original post by QuakAn easy solution would be to use vectors.1. Calculate the vector between the two endpoints of the line: v1 = p1-p02. Calculate an orthogonal vector by exchanging the x and y value and negate one component3. Normalize the orthogonal vector4. Multiply it with your distance and add it to both enpoints to get the endpoints of your new lineExample:P1(2,2), P2(10,6), dist = 2V1 = P2 - P1 = (8,4)Orthogonal vector V2 = (-4,8) or V2 = (4,-8) depending on your offset directionNormalize V2 = (-4,8)/len(V2) = (-4,8)/sqrt(-4²+8²) = (-4,8)/8.94 = (-0.45,0.89)P1' = P1 + V2 * dist = (2,2) + (-0.9,1.78) = (1.1,3.78)P2' likewiseThx Quak! yes this will work. great solution! Seems that there's no faster one.