1

How can I construct the new triangles that exist when adding a point to an existing triangle?

enter image description here

Basically if starting with the red triangle, adding the green point, creates 3 triangles. This part I think is pretty straight forward: I would determine what triangle the point falls inside and then create 3 triangles out of the given 4 points.

But what about the purple point? This falls on an edge and creates 4 new triangles.

Is there a way to cover all cases for adding a point and creating new triangles?

And how do I make sure the purple point is on the edge and not slightly away from it?

You can provide an answer in any language, but Lua would be preferred.

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
RenaissanceProgrammer
  • 404
  • 1
  • 11
  • 30
  • 2
    Using floating-point coordinates, I'm afraid you can never completely be sure that the purple point is "exactly" on the edge and not just "approximately" on the edge. But that's probably okay. You can have some tolerance and say that if it's too close to the edge, it shouldn't create additional "very flat" triangles. – Stef Mar 23 '22 at 15:16
  • Somewhat related: [In Delaunay triangulation D(P), If one point is added in point set P, then all the triangulation is broken?](https://stackoverflow.com/questions/39740623/in-delaunay-triangulation-dp-if-one-point-is-added-in-point-set-p-then-all-t) – Stef Mar 23 '22 at 15:19
  • @Stef since OP never stated any programming language or implementation method (there is only an `algorithm` in tags) we might as well guess this can be done with algebraic geometry. In which case you just calculate if the point is on the line, that's it. OP didn't give too much details here. – alex Mar 23 '22 at 15:36
  • @alex You could make a suggestion to the OP to help them improve their question, rather than tell me that I missed an occasion to be pedantic ;-) – Stef Mar 23 '22 at 15:38
  • @Stef hahah that's true :) – alex Mar 23 '22 at 15:40
  • I added a note on language preference. – RenaissanceProgrammer Mar 23 '22 at 15:41
  • @alex but how would I determine which line? Looping through all lines seems bad especially with more and more points and triangles added to the whole. I did see some other algorithm that uses a “line thickness” variable: http://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html I think I can try to apply that – RenaissanceProgrammer Mar 23 '22 at 15:43
  • You could do something like a Voronoi partitioning based on vertices and update it when new points arrive. This way you could have a heuristic for which lines to check. – alex Mar 23 '22 at 15:52

0 Answers0