Rev 18517 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
18506 | bpr | 1 | !set slib_header_hyptiling=\ |
18430 | bpr | 2 | \\ -----------------------------------------------------------------------------------\ |
3 | \\ Action du groupe de Moebius etendu sur le disque de Poincare\ |
||
4 | \\ -----------------------------------------------------------------------------------\ |
||
5 | \\ Homographie ou antihomographie selon que g[3] vaut 0 ou 1.\ |
||
6 | mob(g,z)=if(g[3],z=conj(z));(g[1]*z+g[2])/(conj(g[2])*z+conj(g[1]));\ |
||
7 | \\ Produit et inverse dans le groupe de Moebius etendu\ |
||
8 | mobx(g)=[g[1],g[2];conj(g[2]),conj(g[1])];\ |
||
9 | mob_mul(g1,g2)=my(m=mobx(g1)*mobx(if(g1[3],conj(g2),g2)));[m[1,1],m[1,2],g1[3]!=g2[3]];\ |
||
10 | mob_inv(g)=if(g[3],[g[1],-conj(g[2]),1],[conj(g[1]),-g[2],0]);\ |
||
18513 | bpr | 11 | \\ Homographie (et anti) qui envoie 0 sur a et 1 sur b, avec a \in D et b a l'horizon\ |
18502 | bpr | 12 | mob_ori(a,b,c)=my(e=sqrt(b),g1=(e-conj(e)*a)/(1-norm(a)));[g1,a*conj(g1),c];\ |
18517 | bpr | 13 | \\ Reflexion par rapport a la geodesique qui joint a et b\ |
18430 | bpr | 14 | mob_ref(a,b)={\ |
15 | my(num=a*b*conj(a-b)+b-a,den=conj(a)*b-conj(b)*a,c,d,h);\ |
||
16 | d=if(norm(den)*1e8<norm(num),\ |
||
17 | if (norm(b)<norm(a),sqrt(a/conj(a)),sqrt(b/conj(b))),\ |
||
18 | c=num/den;(1+sqrt(1-norm(c)))/conj(c));\ |
||
18502 | bpr | 19 | h=mob_ori(a,d);\ |
18430 | bpr | 20 | mob_mul(h,mob_mul([1,0,1],mob_inv(h)))\ |
21 | };\ |
||
18513 | bpr | 22 | lft_fwd(g,beta,l)=my(e=exp(I*beta/2));mob_mul(g,[e,e*l,0]);\ |
18430 | bpr | 23 | \ |
18529 | bpr | 24 | hyp_pav(v,d,z0,eps)={\ |
25 | my(n=#v,a,b,s,s1,s2,t,t1,t2,g,gg,cd0,cd1,cdd1,cd2,r2,f1,v1,w0,z,limit,centres);\ |
||
18451 | bpr | 26 | if(eps>=1,limit=eps;eps=0,limit=1000);\ |
18430 | bpr | 27 | r2=(1-eps)^2;\ |
18449 | bpr | 28 | if(!v,return(0));\ |
18430 | bpr | 29 | \\ Les reflexions qui engendrent W\ |
30 | g=vector(n,i,mob_ref(v[i],v[i%n+1]));\ |
||
31 | \ |
||
18513 | bpr | 32 | \\ Creation du premier pave et de son squelette\ |
18529 | bpr | 33 | \\ Pour chaque sommet, [arite restante, derniere arete cree, affixe, type, dans le disque?]\ |
34 | cd2=List(vector(n,s,[d[s]-2,if(s==1,n,s),v[s],s,norm(v[s])<r2]));\ |
||
35 | \\ Pour chaque arete, [origine, extremite, type, premier polygone borde, active?]\ |
||
18430 | bpr | 36 | cd1=List(vector(n,a,[a,a%n+1,a,1,cd2[a][4]||cd2[a%n+1][4]]));\ |
18513 | bpr | 37 | \\ Pour chaque arete duale [pave origine, pave extremite, arete croisee]\ |
38 | cdd1=List();\ |
||
39 | \\ Pour chaque pave, ses aretes et l'élément du groupe\ |
||
18430 | bpr | 40 | cd0=List([vector(n+1,a,if(a>n,[1,0,0],a))]);\ |
41 | \ |
||
18449 | bpr | 42 | while(#cd0<limit&&f1<#cd1, f1+=1; v1=cd1[f1]; if(v1[5],\ |
18430 | bpr | 43 | s=v1[3]; \\ type de l'arete (ambigu)\ |
44 | \\ Nouveau pave et ses aretes, manquantes ou pas\ |
||
45 | w0=vector(n+1);\ |
||
46 | w0[n+1]=gg=mob_mul(cd0[v1[4]][n+1],g[s]);\ |
||
18513 | bpr | 47 | w0[s]=a=f1; cd1[a][5]=0; listput(cdd1,[v1[4],#cd0+1,a]);\ |
18430 | bpr | 48 | s1=cd1[a][1]; s2=cd1[a][2];\ |
49 | b=cd0[v1[4]][s%n+1];\ |
||
50 | if(s2!=cd1[b][1]&&s2!=cd1[b][2],t=s1;s1=s2;s2=t); \\ arete mal orientee\ |
||
18457 | bpr | 51 | t1=(s-2)%n+1;\ |
52 | while(!cd2[s1][1]&&!w0[t1], \\ aretes precedent f1 qui sont deja la\ |
||
18513 | bpr | 53 | w0[t1]=a=cd2[s1][2]; cd1[a][5]=0; listput(cdd1,[cd1[a][4],#cd0+1,a]);\ |
18457 | bpr | 54 | s1=cd1[a][1]+cd1[a][2]-s1; t1=(t1-2)%n+1);\ |
55 | t2=s%n+1;\ |
||
56 | while(!cd2[s2][1]&&!w0[t2], \\ aretes suivant f1 qui sont deja la\ |
||
18513 | bpr | 57 | w0[t2]=a=cd2[s2][2]; cd1[a][5]=0; listput(cdd1,[cd1[a][4],#cd0+1,a]);\ |
18457 | bpr | 58 | s2=cd1[a][1]+cd1[a][2]-s2; t2=t2%n+1);\ |
59 | while(t1!=t2, \\ Il y a au moins deux aretes a creer\ |
||
60 | if(s1<s2,\ |
||
61 | z=mob(gg,v[t1]);\ |
||
18529 | bpr | 62 | listput(cd2,[d[t1]-1,#cd1+1,z,t1,norm(z)<r2]);\ |
63 | listput(cd1,[s1,#cd2,t1,#cd0+1,cd2[s1][5]||cd2[#cd2][5]]); w0[t1]=#cd1;\ |
||
18457 | bpr | 64 | cd2[s1][1]-=1; cd2[s1][2]=#cd1; s1=#cd2; t1=(t1-2)%n+1,\ |
65 | z=mob(gg,v[t2%n+1]);\ |
||
18529 | bpr | 66 | listput(cd2,[d[t2%n+1]-1,#cd1+1,z,t2%n+1,norm(z)<r2]);\ |
67 | listput(cd1,[s2,#cd2,t2,#cd0+1,cd2[s2][5]||cd2[#cd2][5]]); w0[t2]=#cd1;\ |
||
18457 | bpr | 68 | cd2[s2][1]-=1; cd2[s2][2]=#cd1; s2=#cd2; t2=t2%n+1));\ |
18529 | bpr | 69 | listput(cd1,[s1,s2,t1,#cd0+1,cd2[s1][5]||cd2[s2][5]]); w0[t1]=#cd1;\ |
18457 | bpr | 70 | cd2[s1][1]-=1; cd2[s1][2]=#cd1; cd2[s2][1]-=1; cd2[s2][2]=#cd1;\ |
71 | listput(cd0,w0)));\ |
||
18529 | bpr | 72 | centres=vector(#cd0);\ |
18430 | bpr | 73 | for(f=1,#cd0,\ |
18529 | bpr | 74 | w=cd0[f]; g=w[#w]; centres[f]=mob(g,z0); w[#w]=g[3];\ |
75 | a=cd1[w[1]];b=cd1[w[n]];\ |
||
18430 | bpr | 76 | s=a[1];if(s!=b[1]&&s!=b[2],s=a[2]);\ |
77 | for(i=1,n,a=cd1[w[i]];w[i]=s;s=a[1]+a[2]-s);\ |
||
78 | cd0[f]=w);\ |
||
18529 | bpr | 79 | [vector(#cd2,i,cd2[i][3..4]),Vec(cd0),Vec(cd1),centres,Vec(cdd1)]\ |
18430 | bpr | 80 | };\ |
81 | abc(A,B,C)={\ |
||
82 | if (A+B+C >= Pi, return(0));\ |
||
83 | my(cha=(cos(A)+cos(B)*cos(C))/(sin(B)*sin(C)),\ |
||
84 | chb=(cos(B)+cos(A)*cos(C))/(sin(A)*sin(C)),\ |
||
85 | chc=(cos(C)+cos(B)*cos(A))/(sin(B)*sin(A)));\ |
||
86 | [sqrt((cha-1)/(cha+1)),sqrt((chb-1)/(chb+1)),sqrt((chc-1)/(chc+1))]\ |
||
87 | };\ |
||
18529 | bpr | 88 | tangentiel(a,auCentre)={\ |
89 | my(l,cs=apply(x->cos(x/2),a),rays=vector(1+#a),\ |
||
18502 | bpr | 90 | k=solve(t=0,1,vecsum(apply(x->asin(t*x),cs))-Pi),\ |
18513 | bpr | 91 | R=sqrt(2/(1+k)-1), g=[1,0,0], h, res=vector(#a));\ |
18529 | bpr | 92 | if(auCentre,g=lft_fwd(lft_fwd([1,0,0],-asin(k*cs[1]),R),Pi/2,0));\ |
18502 | bpr | 93 | for(i=1,#a,\ |
18529 | bpr | 94 | rays[i]=l=abc(Pi/2,a[i]/2,asin(k*cs[i]))[3];\ |
18502 | bpr | 95 | g=lft_fwd(g,0,l);\ |
96 | res[i]=mob(g,0);\ |
||
97 | g=lft_fwd(g,Pi-a[i],l));\ |
||
18529 | bpr | 98 | rays[#rays]=R;\ |
99 | [res,rays]\ |
||
18502 | bpr | 100 | };\ |
101 | \ |
||
18529 | bpr | 102 | catalan(d,limite,auCentre)={\ |
103 | my([h,rays]=tangentiel(apply(x->2*Pi/x,d),auCentre));\ |
||
104 | [hyp_pav(h,d,if(auCentre,0,rays[#rays]*I),limite),rays];\ |
||
105 | };\ |
||
106 | \ |
||
107 | wims_catalan(d,limite,auCentre,option)={\ |
||
108 | my([pavage,rays]=catalan(d,limite,auCentre));\ |
||
109 | my([sommets,paves,aretes,centres,daretes]=pavage,R,z,p1,p2);\ |
||
110 | my(res0,res1,res2,res3,res4,n=#paves[1]-1,temp);\ |
||
111 | if(option==1 || option==3 ,\ |
||
112 | res1=matrix(#sommets,2,i,j,if(j==1,real(sommets[i][1]),imag(sommets[i][1])));\ |
||
113 | res0=matrix(#paves,n+2,i,j,if(j==1,n,paves[i][j-1]));\ |
||
114 | res2=List(); for(i=1,#paves,listput(res2,Vec(res0[i,])));\ |
||
115 | );\ |
||
116 | if(option==2 || option==3,\ |
||
117 | res3=matrix(#paves,2,i,j,if(j==1,real(centres[i]),imag(centres[i])));\ |
||
118 | temp=vector(#paves,i,List());\ |
||
119 | foreach(daretes,x,listput(temp[x[1]],x[2]));\ |
||
120 | res4=List();\ |
||
121 | for(i=1,#paves,if(#temp[i],listinsert(temp[i],i,1);listput(res4,Vec(temp[i])))));\ |
||
122 | [res1,Vec(res2),res3,Vec(res4)];\ |
||
123 | };\ |