Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/* * This file: * http://anggtwu.net/MAXIMA/bezier1.mac.html * http://anggtwu.net/MAXIMA/bezier1.mac * (find-angg "MAXIMA/bezier1.mac") * Author: Eduardo Ochs <eduardoochs@gmail.com> * * (defun e () (interactive) (find-angg "MAXIMA/bezier1.mac")) * (find-es "maxima" "qdraw-bezier1") * (find-angg "MAXIMA/myqdraw1.mac" "myapply") */ /* bezier4(P0,P1,P2,P3) := block( local(towt, Q0,Q1,Q2, R0,R1, S0), towt(A, B) := A + t*(B-A), [Q0, Q1, Q2] : [towt(P0,P1), towt(P1,P2), towt(P2,P3)], [R0, R1] : [towt(Q0,Q1), towt(Q1,Q2)], [S0] : [towt(R0,R1)], define(S0(t), ev(S0)), ev(S0) )$ */ bezier4_(P0,P1,P2,P3) := block( local(towt, Q0,Q1,Q2, R0,R1, S0), towt(A, B) := A + t*(B-A), [Q0, Q1, Q2] : [towt(P0,P1), towt(P1,P2), towt(P2,P3)], [R0, R1] : [towt(Q0,Q1), towt(Q1,Q2)], [S0] : [towt(R0,R1)], ['P0=P0, 'P1=P1, 'P2=P2, 'P3=P3, 'Q0=Q0, 'Q1=Q1, 'Q2=Q2, 'R0=R0, 'R1=R1, 'S0=S0] )$ bezier4_export(P0,P1,P2,P3) := block( local(b4), b4 : bezier4_(P0, P1, P2, P3), define(Q0(t), subst(b4, Q0)), define(Q1(t), subst(b4, Q1)), define(Q2(t), subst(b4, Q2)), define(R0(t), subst(b4, R0)), define(R1(t), subst(b4, R1)), define(S0(t), subst(b4, S0)) )$ /* (find-es "qdraw" "para") * (find-es "qdraw" "pts") */ mypara(Poft, [opts]) := myapply_fl('para, Poft[1],Poft[2], t,0,1, opts); mypts (PList, [opts]) := myapply_fl('pts, PList, opts); bezier4_paras(P0,P1,P2,P3) := block( local(Q0,Q1,Q2, R0,R1, S0), bezier4_export(P0,P1,P2,P3), [mypara(Q0(t), lc(red)), mypara(Q1(t), lc(red)), mypara(Q2(t), lc(red)), mypara(R0(t), lc(orange)), mypara(R1(t), lc(orange)), mypara(S0(t), lc(forest_green))] )$ bezier4_pts(P0,P1,P2,P3,tt,[opts]) := block( local(Q0,Q1,Q2, R0,R1, S0), bezier4_export(P0,P1,P2,P3), [mypts([Q0(tt),Q1(tt),Q2(tt)], pc(red), opts), mypts([R0(tt),R1(tt)], pc(orange), opts), mypts([S0(tt)], pc(forest_green), opts)] )$ bezier4_all (P0,P1,P2,P3,tt,[opts]) := [bezier4_paras(P0,P1,P2,P3), bezier4_pts (P0,P1,P2,P3,tt,[opts])]$ /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) ** (find-angg "MAXIMA/myqdraw2.mac") load ("~/MAXIMA/myqdraw2.mac"); load("bezier1.mac"); ** define(P(t), bezier4([0,0], [0,1], [1,1], [1,0])); ** define(P(t), bezier4([0,0], [0,2], [1,1], [1,0])); ** define(P(t), bezier4([0,0], [0,0.2], [1,1], [1,0])); ** myopts : []; myopts : [ps(2),pj(1)]; ** [P0,P1,P2,P3] : [[0,0], [0,1], [1,1], [1,0]]; [P0,P1,P2,P3] : [[0,0], [0,1], [2,1], [1,0]]; ** bezier4_paras(P0,P1,P2,P3); ** bezier4_pts (P0,P1,P2,P3, 0.2, myopts); myqdraw(xr(-0.5,2.5),yr(-0.5,2.5), makelist(bezier4_all(P0,P1,P2,P3, ttt, myopts), ttt, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]), []); myqdraw(xr(-0.5,2.5),yr(-0.5,2.5), bezier4_all (P0,P1,P2,P3, 0.2, myopts), bezier4_all (P0,P1,P2,P3, 0.2, myopts), bezier4_all (P0,P1,P2,P3, 0.2, myopts), bezier4_paras(P0,P1,P2,P3), bezier4_pts (P0,P1,P2,P3, 0.2, myopts) ); bezier4_pts (P0,P1,P2,P3, 0.2, myopts); */ /* * Local Variables: * coding: utf-8-unix * End: */