简体   繁体   中英

Calculating edge lengths of triangles obtained from Delaunay's triangulation

I have a set of discrete points and using them, I performed Delaunay's triangulation.

I want to calculate all the edge lengths from a vertex to the neighboring vertices.

How can I do/code this in c++?

I haven't tested the code that you posted, but the problem seems trivial.

  1. In your main function after you draw all the triangles/points, get the list of all the triangles from subdiv with:

     vector<Vec6f> triangleList; subdiv.getTriangleList(triangleList); 

    (just like in the draw_delaunay(...) function)

  2. Now you just iterate the triangles and compare each point of each triangle to your vertex.

  3. If it's the same point as yours, then you calculate the lengths of edges with two other points of the triangle. Length here = L2 norm of the vector v = point - your_vertex = Sqrt(vx^2 + vy^2) .

There may be duplicates of some edges, so if you want to avoid it, just create a set and add all the point there and calculate the norms later.

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