mattrdowney / planetaria

A Unity framework for Euclidean 2-sphere games (e.g. 2D virtual reality games) [quasi-MIT license]
Other
10 stars 2 forks source link

Minimum Convex Hull algorithm #109

Open mattrdowney opened 5 years ago

mattrdowney commented 5 years ago

Concept: take a given point in a point cloud and find the minimum number of points that produce a convex hull encapsulating the object (ties go to minimum volume). Essentially this is finding the nearest neighbors that produce an adjacency graph.

mattrdowney commented 5 years ago

I feel like my prior description is inaccurate, since a triangle in 2D would always be the solution.

mattrdowney commented 5 years ago

Rough algorithm: start at point "origin". Find closest point and create a convex hull going from origin to closest point. for rest of points in non-decreasing (ascending) distances: if convex hull does not include origin break (in 2D) get "left" and "right" point in convex hull (relative) if dot product of current point and "left"/"right" are both less relative to the origin (after normalization) expand convex hull to include point

I know this algorithm is broken, partially because a point with a circle of points around it should return the circle of points (this algorithm has an order dependency, which might be fixed by incorporating an epsilon).

mattrdowney commented 5 years ago

I think another way of describing my goal for this algorithm is:

Initialize an adjacency graph For each point (as long as a point was added in last loop): if point already has a complete convex hull continue find next closest point not already included as a link in graph and create a connection so long as the dot product isn't greater than any adjacent point

mattrdowney commented 5 years ago

Notably, you can imagine going through the closest points in order (closest to furthest) and striking out items with a dot product greater than 1 relative to any previous convex hull point. After that process is done, find the (inverse? - think a minimum rubber band surrounding the points remaining) convex hull of those points that remain (often this would not be different).

mattrdowney commented 5 years ago

This whole process feels very similar to a "skyline" operator.