00001 #include <stdio.h>
00002
00003
00009
00010 typedef struct vertex_struct {
00011 double x,y;
00012 struct vertex_struct *next;
00013 } vtx, *vtx_ptr;
00014
00020
00021 typedef struct polygon_struct {
00022 char name[100];
00023 vtx_ptr last;
00024 } polygon, *polygon_ptr;
00025
00026
00027 #define polygon_get_vertex(poly, vertex) \
00028 ((vertex == NULL) ? poly->last->next : vertex->next)
00029
00030
00031 #define polygon_new_vertex(poly, xx, yy, new_vertex) { \
00032 new_vertex = (vtx_ptr) malloc (sizeof(vtx)); \
00033 new_vertex->x = xx; \
00034 new_vertex->y = yy; \
00035 if (poly->last != NULL) { \
00036 new_vertex->next = poly->last->next; \
00037 poly->last->next = new_vertex; \
00038 } \
00039 else { \
00040 new_vertex->next = new_vertex; \
00041 } \
00042 poly->last = new_vertex; \
00043 }
00044
00045
00046 #define polygon_create(poly) \
00047 poly = (polygon_ptr) malloc(sizeof (polygon)); \
00048 poly->last = NULL;
00049
00050
00051 typedef short quadrant_type;
00052
00053
00054 typedef enum pt_poly_relation {DENTRO, FUERA} pt_poly_relation;
00055
00056 pt_poly_relation point_in_poly(polygon_ptr poly, double x, double y);
00057 int point_on_edge(vtx_ptr vertex1, vtx_ptr vertex2, double x, double y);