void Display() { glClear(GL_COLOR_BUFFER_BIT); // compute transformations here int N = 400; float scale_factor = 0.02f; float c = 0.04f; float fermat = 137.508f / 2.0; for (int i = 0; i < N; i ++){ float theta = i * fermat * (float)M_PI / 180.0f; float r = c * sqrt(theta); glm::mat4 T = glm::translate(glm::mat4(1.0f), glm::vec3(r * cos(theta) , -r * sin(theta) ,0.0f)); glm::mat4 R = glm::rotate(glm::mat4(1.0f), -theta, glm::vec3(0.0f, 0.0f, 1.0f)); glm::mat4 S = glm::mat4(1.0f); S[0][0] = scale_factor; S[1][1] = scale_factor; triangle.Draw(T,R,S); } }
void Triangles::inquire() { int PS=0; cout << flush; Triangles *OldCurrentTh=CurrentTh; CurrentTh = this; if (! Grafh ) InitDraw(); unsigned char c; int rd; float x,y; int setv =0; Int4 nbtrel=0; Int4 * reft = new Int4 [Max(nbt,1L)]; if (NbSubDomains && subdomains[0].head) nbtrel = ConsRefTriangle(reft); else for (Int4 kkk=0;kkk<nbt;kkk++) reft[kkk]=0; // cout << "inquire **********************************************************************"<<endl ; if (verbosity>2) cout << "inquire: Nb de Triangle reel = " <<ConsRefTriangle(reft)<<endl; while (Show("Enter ? for help",PS==0), c=Getxyc(x,y), (c != 'F' && c != 'f') ) { rd = 0; couleur(1); // cout << " #"<< c << "# " << (int) c << " xy=" << x << " "<< y <<endl ; // penthickness(2); if (c=='?') { int i=3; reffecran(); Show("enter a keyboard character in graphic window to do",i++); i++; Show("f: to continue the process",i++); Show("p: openPS file to save plot, P: close PS file ",i++); Show("B: set backgound mesh has drawing mesh",i++); Show("H: show histogramme",i++); Show("i: initDraw",i++); Show("+ or - : zoom + or -",i++); Show("r: redraw , =: reinit the viewport ",i++); Show("Q: quit / abort / stop ",i++); Show("q: show quadtree",i++); Show("g: show geometry",i++); Show("d: show triangle with det = 0",i++); Show("m: show all the metric",i++); Show("V: show all the vertices",i++); Show("T: show all the sub domain ref number",i++); Show("V: show all the vertices",i++); Show("D: Inforce the mesh to be Delaunay",i++); Show("b: show all the boundary edges ref number",i++); Show("k: find the triangle contening the point",i++); Show("v,o or s : print the nearest vertex s=> draw metric o=> optim around (debug)",i++); Show("t: find triangle contening the point with brute force",i++); Show("e: find the nearest edge of triangle contening the point",i++); Show("C: construct the in-circle in anistrope way",i++); } if (c=='p') openPS(0),PS=1; if (c=='P') closePS(),PS=0; if (c=='B') BTh.inquire(); if ( c=='D') { for(int iter=0;iter < 50;iter++) { int k = 0; for (Int4 icount=0; icount<nbv; icount++) { k += vertices[icount].Optim(1,0); } if (k !=0) cout << " Bizarre le maillage n'est pas delaunay nbswap = " << k << endl; else break; } rd =1; } if (c=='H') ShowHistogram(); if (c=='i') {InitDraw(); } if (c=='+'|| c==253) Grafh /= 2.,rd=1,cadreortho(x,y,Grafh); if (c=='-'|| c==250) Grafh *= 2.,rd=1,cadreortho(x,y,Grafh); if (c=='r') rd =1; if (c=='Q') CurrentTh=0,exit(1); if (c=='q' && quadtree) penthickness(2), couleur(6), quadtree->Draw(), couleur(1), penthickness(1); if (c=='g') couleur(6),Gh.Draw(); if (c=='d') { couleur(4); for(int i=0;i<nbt;i++) if(triangles[i].det == 0) { triangles[i].Draw(); cout << " Bizzare " << i << endl; } couleur(1); } if (c=='m') {Int4 i; couleur(2); for (i=0;i<nbv;i++) ((Metric) vertices[i]).Draw(vertices[i]); couleur(1);} if (c=='V') {Int4 i; for (i=0;i<nbv;i++) vertices[i].Draw(); } if (c=='T') { Int4 i; for( i=0;i<nbt;i++) if(reft[i]>=0) { couleur(2+(reft[i])%6); triangles[i].Draw(reft[i]); couleur(1); } } if (c=='b') { Int4 i; reffecran(); for (i=0;i<nbe;i++) edges[i].Draw(edges[i].ref); } if (c=='k') { if(!setv) ReMakeTriangleContainingTheVertex(); R2 P(x,y); I2 I = toI2(P); Icoor2 dete[3]; Triangle * tb = FindTriangleContening(I,dete); penthickness(1); tb->Draw(Number(tb)); penthickness(1); if(tb->link==0) { double a,b; TriangleAdjacent ta=CloseBoundaryEdgeV2(I,tb,a,b); R2 A = *ta.EdgeVertex(0); R2 B = *ta.EdgeVertex(1); Triangle * tt = ta; // tt->Draw(Number(tt)); penthickness(5); // ta.EdgeVertex(0)->MoveTo(); // ta.EdgeVertex(1)->LineTo(); DrawMark(A*a+B*b); penthickness(1); } } if (c=='v' || c=='o' || c=='s' ) { couleur(5); if(!setv) ReMakeTriangleContainingTheVertex(); setv=1; R2 XY(x,y),P; Real8 d; Int4 i,j=0; P = XY - vertices[0].r; d = P*P; for (i=0;i<nbv;i++) { P = XY - vertices[i].r; Real8 dd = P*P; if(dd < d) { j=i; d=dd;}} cout << " sommet " << j << "= " << vertices[j] << ", d = " << d << endl; vertices[j].Draw(j); DrawMark(vertices[j].r); if( c=='s') vertices[j].m.Draw(vertices[j]); if (c=='o') cout << " Nb Swap = " << vertices[j].Optim(1) << endl; couleur(1); } if (c=='t' || c=='c'||c=='e') { couleur(4); R2 XY(x,y); Real8 a12,a02,a01; for (Int4 i=0;i<nbt;i++) { if(triangles[i].det<=0) continue; // cout << " T = " << i << " " << triangles[i].det << " "; // cout << Number(triangles[i][0]) << " " // << Number(triangles[i][1]) << " " // << Number(triangles[i][2]) << " "; // cout << area2(triangles[i][0].r,triangles[i][1].r,triangles[i][2].r) << " " ; // cout << area2(XY,triangles[i][1].r,triangles[i][2].r) << " " ; // cout << area2(triangles[i][0].r,XY,triangles[i][2].r) << " " ; // cout << area2(triangles[i][0].r,triangles[i][1].r,XY) << endl; if( (a12=Area2(XY,triangles[i][1].r,triangles[i][2].r)) < 0) continue; if( (a02=Area2(triangles[i][0].r,XY,triangles[i][2].r)) < 0) continue; if( (a01=Area2(triangles[i][0].r,triangles[i][1].r,XY)) < 0) continue; if(c=='e'|| c=='E') { int ie =0; Real8 am = a12; if(a02 < am) am=a02,ie=1; if(a01 < am) am=a01,ie=2; TriangleAdjacent tta(triangles+i,ie); Vertex *v0 =tta.EdgeVertex(0); Vertex *v1 =tta.EdgeVertex(1); tta.EdgeVertex(0)->MoveTo(); tta.EdgeVertex(1)->LineTo(); cout << " Edge " << Number(tta.EdgeVertex(0)) << " " << Number(tta.EdgeVertex(1)) << endl; for (Int4 k=0;k<nbe;k++) if ( ( edges[k](0) == v0 && edges[k](1) == v1) || ( edges[k](0) == v1 && edges[k](1) == v0) ) cout << " Edge " << k << " on Geo = " << Gh.Number(edges[k].on)<< endl; if(c=='e') { triangles[i].SetUnMarkUnSwap(ie); triangles[i].swapDRAW(ie);} else if(c=='E') { ; } break; } cout << " In triangle " << i << triangles[i]; triangles[i].Draw(i); if(c=='c') { Vertex *s1=&triangles[i][0]; Vertex *sa=&triangles[i][1]; Vertex *sb=&triangles[i][2]; D2 S1(s1->r.x,s1->r.y); D2 SA(sa->r.x,sa->r.y); D2 SB(sb->r.x,sb->r.y); D2 AB= SB-SA; D2 MAB2=SB + SA; D2 M1A=(S1 + SA)*0.5; D2 MAB(MAB2.x*0.5,MAB2.y*0.5); D2 A1=S1-SA; D2 D = S1 - SB ; { Metric M=s1->m; D2 ABo = M.Orthogonal(AB); D2 A1o = M.Orthogonal(A1); penthickness(1); Move(MAB); Line(MAB+ABo); Line(MAB-ABo); Move(M1A); Line(M1A+A1o); Line(M1A-A1o); penthickness(3); // (A+B)+ x ABo = (S1+B)/2+ y A1 // ABo x - A1o y = (S1+B)/2-(A+B)/2 = (S1-B)/2 = D/2 double dd = Abs(ABo.x*A1o.y)+Abs(ABo.y*A1o.x); double d = (ABo.x*A1o.y - ABo.y*A1o.x)*2; // because D/2 cout << " d = " << d << " dd= " << dd << endl; if (Abs(d) > dd*1.e-10) { D2 C(MAB+ABo*((D.x*A1o.y - D.y*A1o.x)/d)); cout << C << s1->r <<sa->r <<sb->r << endl; DrawMark(C); cout << M << " l = "<< M(C-S1) << " lnew = 1 == " ; //M.Draw(R2(C.x,C.y)); M=M/M(C-S1); cout << M(C-S1) << M << endl; M.Draw(R2(C.x,C.y)); } } } break; } cout << " fin recherche triangle " << endl; couleur(1); } if (c=='='||c==249) { rd=1; float hx = (GrafPMax.x-GrafPMin.x); float hy = (GrafPMax.y-GrafPMin.y); Grafh = Max(hx,hy)*0.55; cadreortho((GrafPMin.x+GrafPMax.x)*0.5,(GrafPMin.y+GrafPMax.y)*0.55,Grafh); } penthickness(1); if (rd) reffecran(),Draw(); } // cout << endl; delete [] reft; CurrentTh = OldCurrentTh; }