2

I have 4 points. If I were to draw lines from every point to every other point, I will get 4 exterior lines and 2 lines crossing in the middle. What I'm trying to identify is the point at which the 2 crossing lines intersect. All I know is the coordinates of each of the 4 points (x0, y0, x1, y1, x2, y2, x3, y3).

demonstration pic

Is there a simple solution to this that I'm missing?

Edit: Edit: Fixed. I was missing the two formulas: x = x1 + ua (x2 - x1) and y = y1 + ua (y2 - y1).

Perry Monschau
  • 883
  • 8
  • 22
  • 1
    note that there is also the case when one point is in the interior of the triangle formed by the three other points; then none of the segments intersect. – coproc Apr 25 '17 at 10:31
  • **Solution here:** [Algorithm for intersection of 2 lines](https://stackoverflow.com/a/4543530/8112776) – ashleedawg Jan 13 '21 at 04:32

1 Answers1

2

There is nothing special in intersection of quadrilateral diagonals. Just use any approach for intersection of two line segments. Wiki (note that perhaps point order differs from yours)

MBo
  • 77,366
  • 5
  • 53
  • 86
  • Is there not a simpler way? Something about the relationship between 4 points in space? There are certain assumptions I can make, for example, I know that the crossover point is within the 4 points, and not outside. I can also assume the crossover point is closer to whichever of the 4 points are nearest each other. Or is the simplest way to assume infinite lines and use the intersection formula like you suggest? – Perry Monschau Apr 24 '17 at 19:26
  • No, unfortunately. Knowledge that cross point is inside allows to omit checking whether segments do actually intersect, but calculation of position remains the same (except for special cases like parallelogram). – MBo Apr 25 '17 at 01:49