source: CGBLisp/examples/geometry.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: 2.0 KB
Line 
1/*----------------------------------------------------------------
2 Basic function for construction of equations
3 in Geometric Theorem proving
4----------------------------------------------------------------*/
5put('geometry,1,'version);
6
7define_variable(geqns,[],any);
8define_variable(hypotheses,[],any);
9define_variable(conclusions,[],any);
10define_variable(gvars,[],any);
11define_variable(gparams,[],any);
12define_variable(gindex,1,any);
13define_variable(gparindex,1,any);
14define_variable(gideal,FALSE,any);
15
16ginit():=(geqns:hypotheses:conclusions:gvars:gparams:[],
17 gindex:gparindex:1);
18ghypot():=(hypotheses:geqns,geqns:[]);
19
20gconcl():=(conclusions:geqns,geqns:[]);
21
22gideal():= (gideal:append(hypotheses,
23 makelist(1-genpar()*conclusions[i],i,1,length(conclusions))));
24
25showideal():=expand(gideal);
26
27gstringout(file):=block([val:ev(string(showideal()),grind=true)],
28stringout(file,concat("(string-grobner-system \"",
29val,"\" '",
30lispl(gvars),
31" '",lispl(gparams),")")));
32
33lispl(l):=apply(concat,append(["("],makelist(concat(" ",e," "),e,l),[")"]));
34
35gpoints([L]):=map(lambda([P],
36 P::genpoint(),gvars:append(gvars,eval(P))),L);
37
38garbitrary([L]):=map(lambda([P],gparams:append(gparams,eval(P))),L);
39
40/* X, Y, Z on the plane are colinear */
41collinear(X,Y,Z):=
42 (geqns:endcons(det(matrix(cons(1,X),cons(1,Y),cons(1,Z))),geqns));
43
44/* Vector AB and CD are perpendicular */
45perp(A,B,C,D):= (geqns:endcons((B-A).(D-C),geqns));
46
47/* AB and CD have equal length */
48eqlen(A,B,C,D):=(geqns:endcons((B-A).(B-A)-(D-C).(D-C),geqns));
49
50/* AB and CD are parallel */
51parallel(A,B,C,D):=(geqns:endcons(geqns,det(matrix(B-A,D-C))));
52
53/* M is the midpoint of AB; 2 equations */
54midpoint(M,A,B):=(geqns:append(geqns,2*M-(A+B)));
55
56/* Points A and B are identical */
57identical(A,B):=(geqns:append(geqns,A-B));
58
59/* Generate a point with coords [xi,yi] */
60genpoint():=block([i:gindex],gindex:gindex+1,[concat('x,i),concat('y,i)]);
61
62/* Generate a parameter ui */
63genpar():=block([i:gparindex,sym:concat('u,i)],
64 gvars:endcons(sym,gvars),gparindex:gparindex+1,sym);
65
66
Note: See TracBrowser for help on using the repository browser.