MATLAB: Delaunay Triangulation only for edges below certain length

delaunaymaximum edge lengthtriangulation

Hello, having tried to find out if that works for quite some time, I thought I'll try here.
So basically I am performing this triangulation on a network and at the edges of the image, there are points connected by the triangulation that should not be, and I would like to sort them out by giving a constraint on the maximum edge length of the triangles. Is that possible?
Thanks for any help!

Best Answer

Is it possible? Of course. Compute the edge lengths. Decide which triangle have a longer edge length than what you want.
What will you do with that information? If the anser is you want the Delaunay triangulation to NOT create those triangles, and have it be smart enough to do that, think again. In context of a Delaunay triangulation, that is not an option you have. In fact, there is relatively little in context of a Delaunay triangulation you can do.
A Delaunay triangulation forms a triangulation of a region, such that the boundary of the region will be the convex hull of the data.
Given that, IF the region you want to see triangulated is not a convex region, then expect problems! You will get those long thin triangles. It will fill the gaps around the perimeter of your region where the data is NOT in fact convex.
Is your real question, can you create a triangulation that does NOT fill those gaps, thus not creating long, thin triangles around the perimeter? To some extent, yes, you do have an alternative - an alpha shape. An alpha shape starts with a Delaunay triangulation, then effectively rolls a ball (or sphere in 3-d) of radius alpha around the perimeter. Where the ball can penetrate a facet of the triangulation far enough to touch an interior node, it erodes those simplexes away. Depending on the options chosen, you can allow the code to erode interior holes or not.
xy = rand(100,2);
S = alphaShape(xy)
S =
alphaShape with properties:
Points: [100×2 double]
Alpha: 0.0949990743504186
HoleThreshold: 0
RegionThreshold: 0
plot(S)
The code chose Alpha as 0.094999..., which is pretty small in general. I'd guess an alpha radius of vaguely 1/2 to 2 would be not be unreasonable, since the data is generated from uniform data in the unit square.
S.Alpha = .5
S =
alphaShape with properties:
Points: [100×2 double]
Alpha: 0.5
HoleThreshold: 0
RegionThreshold: 0
plot(S)
So where the alpha ball can penetrate a perimeter facet of the triangulation far enough to TOUCH an internal node, the triangle will be eroded, thus deleted from what you get.
If you know in advance the value of alpha you might want to use, then pass it in directly when you create the shape. Thus use it as:
S = alphaShape(xy,0.5);
I generally find an alpha shape to be moderately insensitive to alpha radius as long as you don't go too small. Make the radius a little bit larger, and you will add a few moderately thin triangles. Go too large, and it starts to turn into the convex hull. Note that an alpha radius of inf will generally be equivalent to the Delaunay triangulation itself.
Finally, you do get two parameters to control hole and region thresholds. Without making this a complete tutorial on the idea, just read the docs for alphaShape. Play with it. Learn how to use the tool.