Algorithm for calculating the most 'even' orientation for edges for tessellated triangles?

懵懂的女人 提交于 2019-12-24 18:43:43

问题


I've inherited some legacy code that rotates edges between triangles for improved topology distribution, this algorithm works well but is quite computationally intensive.

The psudo-code given the quad made up of two triangles that share an edge is:

/* split 0-2 */
score_02 = (area(v0, v1, v2) / perimeter(v0, v1, v2)) + 
           (area(v0, v2, v3) / perimeter(v0, v2, v3));
/* split 1-3 */
score_13 = (area(v1, v2, v3) / perimeter(v1, v2, v3)) + 
           (area(v0, v1, v3) / perimeter(v0, v1, v3));

/* negative number when (0-2) is an improved state */
result = score_13 - score_02;

This works very well and can give nice tessellation on 2D triangulated regions (see example).

My main concern is this is not very efficient (perimeter calculations involve 6 square-root calls).

Are there other/better methods to calculate a relaxed state before (above), after relaxation (below), eg:


Failing to use a good method may:

  • Cause one of the triangles to have zero area
    (depending on what the output is used for, this may have cascading effects - faces with zero area normals for example aren't as easily handled when using as input for other processes).
  • Poor divisions may cause distortion of mapped textures or deform badly.

It's been pointed out (in an answer that is now deleted) that a simple shortest-edge method can be used, however this doesn't give a good distribution (notice the skinny triangles at the boundaries) eg:


Note 1) that this may be a well known problem, since it wasn't documented in the code, its not an easy thing to search for :)

Note 2) so far I didn't seriously look into an alternative method, I may do so and post findings here.


回答1:


You can try producing a constrained delaunay triangulation. This is the "nicest" (provable) triangulation you may have for a given point set.

If you can add more points (without changing the shape) to the interior or the edges (called steiner points), you can guarantee better triangles (in terms of minimum interior angles and area).

See: http://www.cs.cmu.edu/~quake/triangle.defs.html#conform.

CGAL has implementations for these.




回答2:


The code you posted makes a decision "to flip or not to flip" the shared edge between to triangles. It choses the most regular triangle (equilateral is the best) of the two possibilities: with or without edge-flip.

This "most regular" criterium is based in the relation area/perimeter. You don't need a value; just just need the sign of the option1 - option2 result.
So you don't need square-roots. Using the squared terms is enough.

A bit of performance improve can be checked if you use Heron's formula for the area. You can calculate first the square of the perimeter and use it in that formula.

Other way of achieving better regular triangles is using Delaunay condition, which produces the maximal area with the same perimeter. The test meat is flipping an edge if the fourth point is inside the circumcircle defined by the other three points.

The typical name for this test is "InCircle". It's the result of a determinant (see it at the Wikipedia). The three points must be entered in counterclockwise order, or the sign of the determinant changes. The only drawback of this determinant is its numerical issue when the three points are near co-linear.



来源:https://stackoverflow.com/questions/46212151/algorithm-for-calculating-the-most-even-orientation-for-edges-for-tessellated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!