I have A(x1,y1) and B(x2,y2) coordinates.I have the length and angle of the line.
I need to find the parallel line which gives me C(x3,y3) and D(x4,y4) coordinates at a particular distance.Its a slanted line.
Any pseudo code or math formula could help.
Ex: Given Coordinates A(200,0) B(0,450). Angle of the line is 113.962 . Length of the line 492.4.
Help me find C and D coordinates at distance 50 from A, B coordinates.
Please find image below, its a line with angle.
I have A(x1,y1) and B(x2,y2) coordinates.I have the length and angle of the line.
I need to find the parallel line which gives me C(x3,y3) and D(x4,y4) coordinates at a particular distance.Its a slanted line.
Any pseudo code or math formula could help.
Ex: Given Coordinates A(200,0) B(0,450). Angle of the line is 113.962 . Length of the line 492.4.
Help me find C and D coordinates at distance 50 from A, B coordinates.
Please find image below, its a line with angle.
Share Improve this question edited Nov 6, 2018 at 5:18 user10519853 asked Nov 3, 2018 at 15:37 user10519853user10519853 1551 gold badge1 silver badge10 bronze badges 13- how is the distance measured ? is it along x-axis , y-axis or any other angle? – SomeDude Commented Nov 3, 2018 at 15:46
- Just add 50 to the a.x and b.x. The resulting line will be parallel. – bhspencer Commented Nov 3, 2018 at 16:07
- This is pretty basic geometry. Translate A and B by a vector V to get C and D. The length of V is your distance, and the angle of V is some angle that you haven't specified (along the x-axis is straightforward). – Nelfeal Commented Nov 3, 2018 at 16:09
- Its an angular line. Not a vertical or horizontal line. – user10519853 Commented Nov 3, 2018 at 16:22
- Please find attached image @Nelfeal @ bhspencer @ SomeDude. – user10519853 Commented Nov 3, 2018 at 16:29
1 Answer
Reset to default 10Your line has base point (x1,y1)
and direction vector:
(dx, dy) = (x2-x1, y2-y1)
Normalize this vector dividing ponents by vector length:
len = sqrt((x2-x1)^2 + (y2-y1)^2)
(udx, udy) = (dx / len, dy / len)
perpendicular vector:
(px, py) = (-udy, udx)
(note also reverse vector (udy, -udx) to shift onto another side)
Base point for parallel line at distance dist:
(nx, ny) = (x1 -udy * dist, y1 + udx * dist)
Second point, if you need:
(sx, sy) = (nx + dx, ny + dy)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744700408a4588744.html
评论列表(0条)