Which quadrant of two crossing lines does a point fall within

340 Views Asked by At

I have two lines defined by two points each,

Line{(x1, y1), (x2, y2)}

These lines will never be parallel, nor will either ever be completely horizontal nor vertical. I also have a point (x, y).

I need to be able to mathematically find in which "direction" from the crossing of the two Lines the Point is in. By direction I mean above, below, right, left.

I have tried to figure out how to do this, but so far I've had no luck. Anyone knows how to solve this?

1

There are 1 best solutions below

1
On BEST ANSWER
  • Find the intersection of the two lines, which is always possible since they always intersect. Call that point $(x_c, y_c)$

  • Now compare the coordinates of $(x, y)$ w.r.t $(x_c, y_c)$

    • If $x > x_c$ the point is to the right of the intersection
    • If $y > y_c$ the point is above the intersection
    • (...)