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