Sort Coplanar 3D Points Clockwise

14 views (last 30 days)
Alessandro on 2 May 2017
Answered: Greg Dionne on 2 May 2017
I have a set of 3D points that form a polygon. The points are coplanar, due to the fact they are obtained by means of a Voronoi tessellation. I need to compute the area of such polygon. Computing the convex hull is not an option, since the points are coplanar. I thought about computing the centroid and calculating angles but I am struggling to make it work. MWE:
A = [263 274 14.1; 271 276 14.1; 251 296 14.1; 271 300 14.1];
C = mean(A);
and I need the triangulated convex hull or the ID of the points ordered counterclockwise. In this case the answer I need is:
ans = [1 2 4 3 1]
in order to construct a triangulated polygon, of which the calculation of the area is trivial.

Answers (1)

Greg Dionne
Greg Dionne on 2 May 2017
I'd probably just project to 2D first and just take the X/Y from there. I'm not sure if the indices need to be sorted first either, but this might get you closer: polyarea.
Failing that, your idea of computing the centroid will work: use atan2(Y-Yc,X-Xc) to get the angle and then sort.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!