source: CGBLisp/examples/billiard1.macsyma@ 1

Last change on this file since 1 was 1, checked in by Marek Rychlik, 15 years ago

First import of a version circa 1997.

File size: 1.2 KB
Line 
1if get('geometry2, 'version)=false then load("geometry2");
2n:3;
3/* Define points Ai=[xi,yi] */
4for i:0 thru n-1 do
5 A[i]:[concat(x,i),concat(y,i)];
6
7/* Define circle centers Oi=[ui,vi] */
8for i:0 thru n-1 do
9 O[i]:[concat(u,i),concat(v,i)];
10
11/* Define radii and angles */
12for 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 */
20eqns1:makelist(distance(O[i],A[i],R[i]),i,0,n-1);
21
22/* Distance between Ai and A[i+1] is l[i] */
23shift(k):=if k=n-1 then 0 else k+1;
24lshift(k):=if k=0 then n-1 else k-1;
25eqns2: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]] */
28eqns3: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] */
32eqns4: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 */
36eqns:expand(append(eqns1,eqns2,eqns3,eqns4));
37
38/* Introduce simplifications */
39u0:0;
40v0:0;
41u1:1;
42v1:0;
43
44eqns:''eqns;
45stringout("billiard1.out",eqns,listofvars(eqns));
Note: See TracBrowser for help on using the repository browser.