/* See {Tetrahedron.h} */ #include /* Last edited on 2007-02-04 19:03:03 by stolfi */ #define Tetrahedron_C_COPYRIGHT \ "Copyright © 2000,2007 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include #include #include #include #include Place_t MakeTetra(void) { FourPlaces_t a = MakeTetrahedron(); return a.p[0]; } FourPlaces_t MakeTetrahedron(void) { FourPlaces_t co; int i; for (i = 0; i < 4; i++) { co.p[i] = MakeTriangle(); } /* Glue Walls */ SetNextF(co.p[3],Clock(co.p[0])); SetEdgeInfo(co.p[3], PEdge(Clock(co.p[0]))); SetNextF(Clock(co.p[1]), NextE(co.p[0])); SetEdgeInfo(Clock(co.p[1]), PEdge(NextE(co.p[0]))); SetNextF(Clock(PrevE(co.p[0])), co.p[2]); SetEdgeInfo(Clock(PrevE(co.p[0])), PEdge(co.p[2])); SetNextF(Clock(PrevE(co.p[1])), NextE(co.p[2])); SetEdgeInfo(Clock(PrevE(co.p[1])), PEdge(NextE(co.p[2]))); SetNextF(Clock(NextE(co.p[1])), PrevE(co.p[3])); SetEdgeInfo(Clock(NextE(co.p[1])), PEdge(PrevE(co.p[3]))); SetNextF(Clock(PrevE(co.p[2])), NextE(co.p[3])); SetEdgeInfo(Clock(PrevE(co.p[2])), PEdge(NextE(co.p[3]))); SetOrgAll(co.p[0], OrgV(co.p[0])); SetOrgAll(Clock(co.p[0]), OrgV(Clock(co.p[0]))); SetOrgAll(co.p[1], OrgV(co.p[1])); SetOrgAll(PrevE(co.p[1]), OrgV(PrevE(co.p[1]))); Cell_t q = MakeCell(0); SetPnegOfNearbyWalls(co.p[0], q); return co; } Place_t Make12Fold(void) { EightPlaces_t o = MakeOctahedron(); FourPlaces_t t0 = MakeTetrahedron(); FourPlaces_t t1 = MakeTetrahedron(); FourPlaces_t t2 = MakeTetrahedron(); FourPlaces_t t3 = MakeTetrahedron(); FourPlaces_t t4 = MakeTetrahedron(); FourPlaces_t t5 = MakeTetrahedron(); FourPlaces_t t6 = MakeTetrahedron(); FourPlaces_t t7 = MakeTetrahedron(); /* first glue the 8 tetrahedra to the central octahedron */ Glue(t0.p[0],o.p[0],1,TRUE); /* 5 */ Glue(t1.p[0],o.p[1],1,TRUE); /* 6 */ Glue(t2.p[0],o.p[2],1,TRUE); /* 7 */ Glue(t3.p[0],o.p[3],1,TRUE); /* 8 */ Glue(t4.p[0],NextF(t0.p[0]),1,TRUE); /* 5 */ Glue(t5.p[0],NextF(t1.p[0]),1,TRUE); /* 6 */ Glue(t6.p[0],NextF(t2.p[0]),1,TRUE); /* 7 */ Glue(t7.p[0],NextF(t3.p[0]),1,TRUE); /* 8 */ Glue(o.p[4],NextF(t4.p[0]),1,TRUE); /* 5 */ Glue(o.p[5],NextF(t5.p[0]),1,TRUE); /* 6 */ Glue(o.p[6],NextF(t6.p[0]),1,TRUE); /* 7 */ Glue(o.p[7],NextF(t7.p[0]),1,TRUE); /* 8 */ Glue(Clock(NextF(PrevE(t1.p[0]))),NextF(NextE(t0.p[0])),1,TRUE); /* 9 */ Glue(Clock(NextF(PrevE(t2.p[0]))),NextF(NextE(t1.p[0])),1,TRUE); /* 10 */ Glue(Clock(NextF(PrevE(t3.p[0]))),NextF(NextE(t2.p[0])),1,TRUE); /* 11 */ Glue(Clock(NextF(PrevE(t0.p[0]))),NextF(NextE(t3.p[0])),1,TRUE); /* 12 */ Glue(PrevF(NextE(o.p[4])),Clock(PrevF(PrevE(o.p[5]))), 1, TRUE); Glue(PrevF(NextE(o.p[5])),Clock(PrevF(PrevE(o.p[6]))), 1, TRUE); Glue(PrevF(NextE(o.p[6])),Clock(PrevF(PrevE(o.p[7]))), 1, TRUE); Glue(PrevF(NextE(o.p[7])),Clock(PrevF(PrevE(o.p[4]))), 1, TRUE); return t0.p[0]; } Place_t MakeTwoTetra(uint order) { EightPlaces_t a = MakeTetraTopo(order,order); EightPlaces_t b = MakeTetraTopo(order,order); Glue(Spin(b.p[3]),a.p[2],order, TRUE); return b.p[3]; } Place_t MakeThreeTetra(uint order) { EightPlaces_t a = MakeTetraTopo(order,order); EightPlaces_t b = MakeTetraTopo(order,order); EightPlaces_t c = MakeTetraTopo(order,order); Glue(Spin(a.p[1]), b.p[0], order, TRUE); Glue(Spin(b.p[1]), c.p[0], order, TRUE); Glue(Spin(c.p[1]), a.p[0], order, TRUE); return a.p[1]; } Place_t MakeRawTetra(uint order) { EightPlaces_t ca = MakeTetraTopo(order, order); return ca.p[1]; } void FixCoordsTetra(EightPlaces_t *ca, ElemTableRec_t *top, uint order, Coords_t *c) { r4_t o1 = (r4_t){{0.0,0.0,0.0,0.0}}; /* the node (0,0,0,0) */ r4_t o2 = (r4_t){{1.0,0.0,1.0,0.0}}; /* the node (1,0,1,0) */ r4_t o3 = (r4_t){{0.0,1.0,1.0,0.0}}; /* the node (0,1,1,0) */ r4_t o4 = (r4_t){{1.0,1.0,0.0,0.0}}; /* the node (1,1,0,0) */ auto void SetCornerCoords(Place_t p, r4_t *cv); auto void SetCoordinatesPrimal(Place_t p, r4_t *o); /* Set the node coordinates along the primal edge of topological tetrahedron. */ auto void SetCoordinatesDual(Place_t p, r4_t *o); /* Set the node coordinates along the dual edge of topological tetrahedron. */ void SetCornerCoords(Place_t p, r4_t *cv) { c->e[OrgV(p)->num] = *cv; } void SetCoordinatesPrimal(Place_t p, r4_t *o) { int i; for (i = 1; i < order; i++) { p = Clock(PrevE(NextF(NextE(p)))); double x = ((double)i)/((double)order); c->e[OrgV(p)->num] = (r4_t){{o->c[0], o->c[1]+x, o->c[2]+x, o->c[3]}}; } } void SetCoordinatesDual(Place_t p, r4_t *o) { int i; for (i = 1; i < order; i++) { p = Clock(PrevE(NextF(NextE(p)))); double x = ((double)i)/((double)order); c->e[OrgV(p)->num] = (r4_t){{o->c[0], o->c[1]+x, o->c[2]-x, o->c[3]}}; } } /* Set the corners */ SetCornerCoords(ca->p[0], &o1); SetCornerCoords(ca->p[3], &o2); SetCornerCoords(ca->p[4], &o3); SetCornerCoords(ca->p[6], &o4); SetCoordinatesPrimal(ca->p[0], &o1); SetCoordinatesDual(ca->p[3], &o2); } #define Tetrahedron_C_author \ "Created by L. A. P. Lozada, 2000.\n" \ "Modification history:\n" \ " 30-08-2000 : [???] Nice version of the {MakeOctahedron} procedure.\n" \ " 19-09-2000 : [???] Added the procedure {MakeDodecahedronTriang}.\n" \ " 27-10-2000 : [???] Modified {SetCubeProperties} procedure.\n" \ " 01-02-2007 : [???] Added {Make12Fold} from {MakeComplexWf.c}.\n" \ " 01-02-2007 : [???] Added {MakeTwoTetra}, {MakeThreeTetra} from {MakeComplexWf.c}.\n" \ " 01-02-2007 : [???] Added {FixCoordsTetra} from {MakeRawTetra.c}."