简体   繁体   中英

Create 2d triangles from 2d points

I have to make 2d triangles from a list of 2d points with a condition: length of any edge can't be longer than a predefined constant.

Something like this: 替代文字

Do you know any algorithm that can do this? Or any advise?

Thanks!

Try Delaunay triangulation , then remove any edges which are too long.

From the above article, you see a link to CGAL's 2D triangulation page .

First, generate all possible edges (ie connecting a pair of vertices that are closer than the constant). Then when two of them intersect, remove one of them. Repeat this step until there are no intersections.

This solution is quite primitive, it's probably possible to do it faster.

I like svick's answer -

when implementing I would do the following

  1. calculate the lines between every pair of points
  2. Sort the list by length
  3. Remove all lines longer than your threshold
  4. Continue down the list (longest to shortest) if it crosses another line then remove it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM