if get('geometry2, 'version)=false then load("geometry2"); n:3; /* Define points Ai=[xi,yi] */ for i:0 thru n-1 do A[i]:[concat(x,i),concat(y,i)]; /* Define circle centers Oi=[ui,vi] */ for i:0 thru n-1 do O[i]:[concat(u,i),concat(v,i)]; /* Define radii and angles */ for i:0 thru n-1 do ( R[i]:concat(R,i), COS_P[i]:concat(Cos,i), SIN_P[i]:concat(Sin,i), l[i]:concat(l,i) ); /* Ai is on the circle with center Oi and radius Ri */ eqns1:makelist(distance(O[i],A[i],R[i]),i,0,n-1); /* Distance between Ai and A[i+1] is l[i] */ shift(k):=if k=n-1 then 0 else k+1; lshift(k):=if k=0 then n-1 else k-1; eqns2:makelist(distance(A[i],A[shift(i)],l[i]),i,0,n-1); /* Pi is the angle between [Ai,Oi] and [A[i],A[i+1]] */ eqns3:apply(append,makelist(angle(cos_p[i],sin_p[i],O[i],A[i],A[shift(i)], r[i],l[i]),i,0,n-1)); /* Pi is the angle between [A[i-1],A[i]] and [Ai,Oi] */ eqns4:apply(append,makelist(angle(cos_p[i],sin_p[i],A[lshift(i)],A[i],O[i], l[lshift(i)],r[i]),i,0,n-1)); /* Combine all equations */ eqns:expand(append(eqns1,eqns2,eqns3,eqns4)); /* Introduce simplifications */ u0:0; v0:0; u1:1; v1:0; eqns:''eqns; stringout("billiard1.out",eqns,listofvars(eqns));