Annotation of OpenXM/src/cfep/tests/ccurve.rr, Revision 1.2
1.1 takayama 1: /* From OpenXM: OpenXM/src/asir-contrib/packages/src/ccurve.rr,v 1.1 2004/03/11 12:25:20 takayama Exp */
2: /* From asir-book/Prog/ccurve */
1.2 ! takayama 3: import("glib")$
1.1 takayama 4: def cCurve(P) {
5: if (length(P) < 2) return(0);
6: A = P[0][0];
7: B = P[0][1];
8: C = P[1][0];
9: D = P[1][1];
10: Tmp = [[A,B],[(A+D+C-B)/2,(B+A+D-C)/2],
11: [(A+D+C-B)/2,(B+A+D-C)/2],[C,D]];
12: return(append2(Tmp,cCurve(cdr(cdr(P)))));
13: }
14: def append2(A,B) {
15: if (type(B) == 0) return A;
16: else return append(A,B);
17: }
18: def ccurve(N) {
19: Tmp = [[0,0],[1,0]];
20: for (I=0; I<N; I++) {
21: Tmp = cCurve(Tmp);
22: print(Tmp);
23: }
24: glib_window(-1,-1,2,0.5);
25: for (I=0; I<length(Tmp)-1; I++) {
1.2 ! takayama 26: glib_line(Tmp[I][0],Tmp[I][1],Tmp[I+1][0],Tmp[I+1][1]); glib_flush();
1.1 takayama 27: }
28: }
29: ccurve(6); glib_flush();
30: "Type in, for example, ccurve(8);";
31:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>