C# Class Project290.Physics.Common.ConvexHull.GiftWrap

Afficher le fichier Open project: scastle/Solitude

Méthodes publiques

Méthode Description
GetConvexHull ( Vertices vertices ) : Vertices

Find the convex hull of a point cloud using "Gift-wrap" algorithm - start with an extremal point, and walk around the outside edge by testing angles. Runs in O(N*S) time where S is number of sides of resulting polygon. Worst case: point cloud is all vertices of convex polygon: O(N^2). There may be faster algorithms to do this, should you need one - this is just the simplest. You can get O(N log N) expected time if you try, I think, and O(N) if you restrict inputs to simple polygons. Returns null if number of vertices passed is less than 3. Results should be passed through convex decomposition afterwards to ensure that each shape has few enough points to be used in Box2d. Warning: May be buggy with colinear points on hull.

Method Details

GetConvexHull() public static méthode

Find the convex hull of a point cloud using "Gift-wrap" algorithm - start with an extremal point, and walk around the outside edge by testing angles. Runs in O(N*S) time where S is number of sides of resulting polygon. Worst case: point cloud is all vertices of convex polygon: O(N^2). There may be faster algorithms to do this, should you need one - this is just the simplest. You can get O(N log N) expected time if you try, I think, and O(N) if you restrict inputs to simple polygons. Returns null if number of vertices passed is less than 3. Results should be passed through convex decomposition afterwards to ensure that each shape has few enough points to be used in Box2d. Warning: May be buggy with colinear points on hull.
public static GetConvexHull ( Vertices vertices ) : Vertices
vertices Vertices The vertices.
Résultat Vertices