/* See {Polygon.h} */ #include /* Last edited on 2007-01-27 14:48:44 by stolfi */ #define Polygon_C_COPYRIGHT \ "Copyright © 2000,2007 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include #include #include #include #include #include #include Place_t MakeGon(uint n) { Place_t sp[n]; Node_t sv[n]; int i; for (i = 0; i < n; i++) { sp[i] = MakeWedge(); sv[i] = MakeNode(); } Wall_t f = PWall(sp[0]); for (i = 0; i < n; i++) { PWedge(sp[i])->num = 0; SetOrg(sp[i],sv[i]); SetOrg(Clock(sp[i]),sv[(i+1) % n]); SetNextE(sp[i],sp[(i+1) % n]); SetWallInfo(sp[i],f); } return sp[0]; } Place_vec_t MakeGonFull(uint n) { Place_vec_t sp = Place_vec_new(n); Node_t sv[n]; int i; for (i = 0; i < n; i++) { sp.el[i] = MakeWedge(); sv[i] = MakeNode(); } Wall_t f = PWall(sp.el[0]); for (i = 0; i < n; i++) { PWedge(sp.el[i])->num = 0; SetOrg(sp.el[i],sv[i]); SetOrg(Clock(sp.el[i]),sv[(i+1) % n]); SetNextE(sp.el[i],sp.el[(i+1) % n]); SetWallInfo(sp.el[i],f); } return sp; } void FixCoordsGon(uint order, Place_t p, Topology_t *top, Coords_t *c) { auto void SetCoords(Place_t e, r4_t cv); /* set the coordinates of the node OrgV(e). */ auto void SetCoords(Place_t e, r4_t cv) { c->el[OrgV(e)->num] = cv; } Place_t q = p; int i; for (i = 0; i < order; i++) { double theta = 2*i*M_PI/order; double x = cos(theta); double y = sin(theta); SetCoords(q, (r4_t){{x,y,0,1}}); q = NextE(q); } } #define Polygon_C_author \ "Created by L. A. P. Lozada, 2000.\n" \ " 26-01-2007 : Converted to C by J. Stolfi; got {FixCoordsGon} from\n" \ " {MakeGon.c}"