-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|294|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Pakz
Created : 21 November 2019
 
Language : Monkey2

Convex Hull or Gift Wrapping algorithm

create lines around set of points.



I noticed this algorithm on the coding train a while ago. I thought it might be to complex for me to understand or to recreate but I noticed a while ago I also created a function used by this algorith,. This one the orientation function returns if a point is left or center or right of a line.
This algorithm here. The gift wrapping of convex hull create lines around a series of points, wrapping as to say.

It starts at the left most point and checks other points on the orientation if it is on the left side thus wrapping it.

I started creating it myself at first but failing later I looked at a javascript example and was able to fix the main for loop that does the magic.

I think this one also is a bit like my point in polygon collision but this one creates the polygon around the point(s).

 

Comments