pick point with min y, if more than one, pick min x with y, say P

sort the angles of all points to P

while(pts>=3 && first_three_points_collinear) remove_second_point

while(pts>=3 && last_three_points_collinear) remove_second_last_point for(i=3; i<pts; ++i) {

while(i && V

*,V[i-1],V[0] collinear) {*

remove V[i-1];

--pts;

--i;

}

while(i>=3 && half_angle(V[0],V[i-2],V[i-1],V

remove V[i-1];

--pts;

--i;

}

while(i>=3 && half_angle(V[0],V[i-2],V[i-1],V

*) ) {*

remove V[i-1];

--pts;

--i;

}

}

half_angle returns true if angle V[i-1] is larger than 180 degrees, i need V[0] because it helps to know which angle on V[i-1] (there're two) to be considered, ie. which side is in the polygon or outsideremove V[i-1];

--pts;

--i;

}

}

half_angle returns true if angle V[i-1] is larger than 180 degrees, i need V[0] because it helps to know which angle on V[i-1] (there're two) to be considered, ie. which side is in the polygon or outside