kylebarron/snap-to-tin

Bug: overlapping line and triangle edge returns two different intersection points

Closed this issue · 1 comments

E.g.

  test("overlapping line and triangle edge", () => {
    const line = [
      [0, 0],
      [0, 1]
    ];
    const triangle = [
      [0, 0],
      [0, 1],
      [1, 0],
      [0, 0]
    ];
    const result = lineTriangleIntersect(line, triangle);
    // Note, currently returns duplicates
    expect(result).toStrictEqual([]);
	// false -> [[0, 0], [0, 1]]
  });

While the line-line intersection of overlapping lines is false, the overlapping line intersects the other two edges of the triangle at those points.

Actually this is good behavior... If an actual line is overlapping a triangle edge, it would be good to return both those points, so that the altitude is found for each, and then the line follows the edge in 3 dimensions.