#ifndef _HULL_H_ #define _HULL_H_ #ifdef __cplusplus extern "C" { #endif typedef struct { float x; float y; int id; } point; typedef struct { point **stack; int stack_pointer; int stack_cap; } point_stack; #define NEG(x) (((x)<0)?1:0) #define left_turn(p0,p1,p2) ( NEG(((p2)->x-(p0)->x)*((p1)->y-(p0)->y)- \ ((p2)->y-(p0)->y)*((p1)->x-(p0)->x)) ) #define POS(x) ((x)>0?1:0) #define clockwise(p0,p1,p2) ( (((p1)->x-(p0)->x)*((p2)->y-(p0)->y)- \ ((p1)->y-(p0)->y)*((p2)->x-(p0)->x)) ) #define ZERO(x) (!(x)) #define collinear(p0,p1,p2) ( ZERO(((p2)->x-(p0)->x)*((p1)->y-(p0)->y)- \ ((p2)->y-(p0)->y)*((p1)->x-(p0)->x)) ) point* pop(point_stack*); void destroy_stack(point_stack *); point_stack *graham_scan(point *q, int q_len); #ifdef __cplusplus } #endif #endif/*_HULL_H_*/