[1] | 1 | if get('geometry2, 'version)=false then load("geometry2");
|
---|
| 2 | n:3;
|
---|
| 3 | /* Define points Ai=[xi,yi] */
|
---|
| 4 | for i:0 thru n-1 do
|
---|
| 5 | A[i]:[concat(x,i),concat(y,i)];
|
---|
| 6 |
|
---|
| 7 | /* Define circle centers Oi=[ui,vi] */
|
---|
| 8 | for i:0 thru n-1 do
|
---|
| 9 | O[i]:[concat(u,i),concat(v,i)];
|
---|
| 10 |
|
---|
| 11 | /* Define radii and angles */
|
---|
| 12 | for i:0 thru n-1 do (
|
---|
| 13 | R[i]:concat(R,i),
|
---|
| 14 | COS_P[i]:concat(Cos,i),
|
---|
| 15 | SIN_P[i]:concat(Sin,i),
|
---|
| 16 | l[i]:concat(l,i)
|
---|
| 17 | );
|
---|
| 18 |
|
---|
| 19 | /* Ai is on the circle with center Oi and radius Ri */
|
---|
| 20 | eqns1:makelist(distance(O[i],A[i],R[i]),i,0,n-1);
|
---|
| 21 |
|
---|
| 22 | /* Distance between Ai and A[i+1] is l[i] */
|
---|
| 23 | shift(k):=if k=n-1 then 0 else k+1;
|
---|
| 24 | lshift(k):=if k=0 then n-1 else k-1;
|
---|
| 25 | eqns2:makelist(distance(A[i],A[shift(i)],l[i]),i,0,n-1);
|
---|
| 26 |
|
---|
| 27 | /* Pi is the angle between [Ai,Oi] and [A[i],A[i+1]] */
|
---|
| 28 | eqns3:apply(append,makelist(angle(cos_p[i],sin_p[i],O[i],A[i],A[shift(i)],
|
---|
| 29 | r[i],l[i]),i,0,n-1));
|
---|
| 30 |
|
---|
| 31 | /* Pi is the angle between [A[i-1],A[i]] and [Ai,Oi] */
|
---|
| 32 | eqns4:apply(append,makelist(angle(cos_p[i],sin_p[i],A[lshift(i)],A[i],O[i],
|
---|
| 33 | l[lshift(i)],r[i]),i,0,n-1));
|
---|
| 34 |
|
---|
| 35 | /* Combine all equations */
|
---|
| 36 | eqns:expand(append(eqns1,eqns2,eqns3,eqns4));
|
---|
| 37 |
|
---|
| 38 | /* Introduce simplifications */
|
---|
| 39 | u0:0;
|
---|
| 40 | v0:0;
|
---|
| 41 | u1:1;
|
---|
| 42 | v1:0;
|
---|
| 43 |
|
---|
| 44 | eqns:''eqns;
|
---|
| 45 | stringout("billiard1.out",eqns,listofvars(eqns));
|
---|