Question

i am having a line with (x1,y1) and (x2,y2) and a point (x3,y3). i need to draw a line from (x3,y3) to the line with 90 degrees. so that it touches on line at a point (x4,y4). how can i find point (x4,y4).

Thanks in advance.

Was it helpful?

Solution

Consider {x1,y1} to {x2,y2} to be a vector, “vector1”. Now make another vector, “vector2”, with point {x3,y3} and another point which is one unit away from {x3,y3} at an angle that’s perpendicular to vector1: e.g., if vector1 is at angle ‘p’, your want to make the second point in vector2 {x3+cos(p+90º),y3+sin(p+90º)}.

Now you have these two vectors, you just need to figure out where they cross. You can google this: here’s one page I found.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top