I have a path defined by a list of (x, y) coordinates and I want to create two additional paths, one offset by a distance of 0.25, the other by -0.25.
I think that could be done by finding parallel lines for each coordinate pair in the path. I don't know where to start, however.
Thank you for any help.
The equation of a straight line is y = mx + c. You can work out m and c for the first line because you have pairs of x's and y's. The two parallel lines will have the same m's and different c's which you must find. The two new c's will differ from the originally c by the same value but in different directions - one up and one down.
This is easier to see with a diagram: 1. Draw two parallel equally spaced lines with positive slopes. 2. Draw a right angle triangle between the two lines with the hypoteneuse along the upper one and horizontal (b) and vertical (a) lines for the other two sides joining on the lower line. 3. Divide that triangle into two right angle triangles (the dividing line will be 0.25 long).
Now m = a/b which equals the tangent of the lower left angle q. Therefore q = tan^-1 m, but this is also the lower angle in the triangle with a vertical side. So cos(tan^-1 m) = 0.25/a, which can easily be rearranged for a. So just add it to c for one of the lines and subtract it for the other.