Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/* * This file: * http://anggtwu.net/myqdraw/myqdraw3.mac.html * http://anggtwu.net/myqdraw/myqdraw3.mac * (find-myqdraw "/myqdraw3.mac") * Author: Eduardo Ochs <eduardoochs@gmail.com> * Homepage: http://anggtwu.net/eev-qdraw.html * License: Public Domain * Version: 2024nov23 * * This is "myqdraw3.mac" - my third attempt to extend qdraw * in useful ways. Qdraw is this: * * https://home.csulb.edu/~woollett/mbe.html * https://home.csulb.edu/~woollett/mbe13qdraw.pdf * https://home.csulb.edu/~woollett/qdraw.mac * (find-windows-beginner-intro "12. Install qdraw") * * and myqdraw is explained here: * * http://anggtwu.net/eev-qdraw.html * * This file defines `myqdraw' and several variants for it. * `myqdraw' is like `qdraw', but it flattens its arguments. * Here are the explanations for the suffixes and prefixes: * * The prefix "my" means "flatten the arguments". * The suffix "v" means "vertical output" (for debugging). * The suffix "1" has several meanings: * qdraw1 (line(1,2,3,4)) returns drlist instead of drawing it * myqdraw1 (line(1,2,3,4)) returns drlist instead of drawing it * myqdraw1v(line(1,2,3,4)) returns drlist in "vertical format" * myqdraw1.mac is an older version of these functions * myapply (f,[L]) receives f and a vararg * myapply1(f, L ) receives a single list instead of a vararg * * The suffix "p" means "to pdf". * The variants with "p" are defined here: * (find-myqdraw "topdf1.mac" "myqdrawp-modes") * * This file loads both "qdraw.mac" and "topdf1.mac". See: * (find-angg ".maxima/maxima-init.mac" "load_qdraw") * (find-myqdraw "topdf1.mac") * * (defun q3 () (interactive) (find-myqdraw "/myqdraw3.mac")) * (defun q2 () (interactive) (find-myqdraw "/myqdraw2.mac")) * * «.load» (to "load") * «.myqdraw» (to "myqdraw") * «.myapply» (to "myapply") * «.xyrange» (to "xyrange") * «.myex» (to "myex") * «.myimp» (to "myimp") * «.mypara» (to "mypara") * «.pts_open» (to "pts_open") * «.myPv» (to "myPv") * «.zpts» (to "zpts") * «.myterminalpdf» (to "myterminalpdf") */ /* «load» (to ".load") * See: (find-myqdraw "myqdraw-core.mac") * (find-myqdraw "myqdraw-tex.lisp") * (find-myqdraw "topdf1.mac") * and: http://anggtwu.net/eev-qdraw.html#the-loads * (find-TH "eev-qdraw" "the-loads") */ myqdrawdir : pathname_directory(load_pathname); load(concat(myqdrawdir, "qdraw.mac")); load(concat(myqdrawdir, "myqdraw-core.mac")); load(concat(myqdrawdir, "myqdraw-tex.lisp")); load(concat(myqdrawdir, "topdf1.mac")); /* «xyrange» (to ".xyrange") */ [xmin,ymin, xmax,ymax] : [-1,-1, 5,4]; xyrange0() := [xr(xmin,xmax), yr(ymin,ymax)]; xyrange () := [xr(xmin,xmax), yr(ymin,ymax), more(proportional_axes=xy)]; /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); myqdraw(xyrange(), para(cos(t),sin(t), t,0,2*%pi)); [xmin,ymin, xmax,ymax] : [-2,-2, 10,6]; myqdraw(xyrange(), para(cos(t),sin(t), t,0,2*%pi)); */ /* «myex» (to ".myex") * (find-es "qdraw" "ex") */ myex (fxs,[opts]) := makelist(myapply_fl('ex1, fx, 'x,xmin,xmax, opts), fx,fxs); myex1(fx, [opts]) := myapply_fl('ex1, fx, x,xmin,xmax, opts); /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); [xmin,xmax] : [-2,2]; myqdraw(myex([x,x^2], lc(orange))); myqdraw(myex1(x, lc(orange)), myex1(x^2, lc(red))); */ /* «myimp» (to ".myimp") * (find-es "qdraw" "imp") */ myimp (eqs,[opts]) := myapply_fl('imp, eqs, x,xmin,xmax, y,ymin,ymax, opts); myimp1(eq, [opts]) := myapply_fl('imp1, eq , x,xmin,xmax, y,ymin,ymax, opts); /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); F : x^2 + y^2; myqdraw(xyrange(), myimp([F=1,F=2])); myqdraw(xyrange(), myimp1(F=1, lc(orange)), myimp1(F=2, lc(red))); */ /* «mypara» (to ".mypara") */ mypara(xy,[rest]) := myapply('para, xy[1],xy[2], rest); /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); P(t) := [cos(t),sin(t)]; myqdraw(xyrange(), mypara(P(t)+[2,2], t,0,2*%pi)); */ /* «pts_open» (to ".pts_open") * (find-es "qdraw" "point-types") */ pt_open : pt(6); pt_closed : pt(7); pts_open(coords, [opts]) := [myapply_fl('pts, coords, pc(white),pt_closed,opts), myapply_fl('pts, coords, pt_open, opts)]; /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); myqdraw(xr(-1,4),yr(-1,3), para(x,1, x,1,3), pts_open([[1,1],[2,1]]), pts ([[3,1]])); */ /* «myPv» (to ".myPv") */ myPv (P,v, Popts,[vopts]) := [myapply_fl('pts, [P], Popts), myapply_fl('vector, P,v, vopts)]; myPPe(P0,P1,eps,Popts,[vopts]) := [myapply_fl('pts, [P0,P1], Popts), myapply_fl('vector, P0,(P1-P0)/eps, vopts)]; myPopts (colr) := [pc(colr),ps(2)]; myvopts (colr) := [lc(colr),hl(0.15),ht(f)]; myPv_c (P,v, colr) := myPv (P,v, myPopts(colr), myvopts(colr)); myPPe_c(P0,P1,eps,colr) := myPPe(P0,P1,eps, myPopts(colr), myvopts(colr)); /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); P(t) := [cos(t),sin(t)] + [2,1]; define(vel(t), diff(P(t),t)); myqdraw(xyrange(), mypara (P(t), t,0,2*%pi, lc(orange)), myPv_c (P(1), vel(1), red), myPPe_c(P(2), P(3.2), 1.2, forest_green), myPPe_c(P(2), P(2.5), 0.5, forest_green), myPPe_c(P(2), P(2.2), 0.2, forest_green) ); */ /* «zpts» (to ".zpts") */ ztoxy (z) := [realpart(z), imagpart(z)]; xytoz (x,y) := x + %i*y; zflatten([zs]) := map('ztoxy, flatten(zs)); zpts (zs,[opts]) := myapply_fl('pts, zflatten(zs), opts); /* * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); [xmin,ymin, xmax,ymax] : [-3,-3, 3,3]; a : 1 + %i*1/2; as : makelist(a^n, n,0,10); myqdraw(xyrange(), zpts(as)); */ /* «myterminalpdf» (to ".myterminalpdf") * Similar to: (find-myqdraw "topdf1.mac") * but more primitive. */ myterminalpdf (stem) := more(terminal=pdf, file_name=stem); myincludegraphics(opts,stem) := format("\\includegraphics[~a]{~a.pdf}", opts, stem); /* * (find-sh0 "ls -lAF /tmp/test*") * (find-sh0 "rm -fv /tmp/test*") * * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("myqdraw3.mac"); P(t) := [cos(t),sin(t)] + [2,1]; drawing : [xyrange(), mypara(P(t), t,0,2*%pi)]; myqdraw(drawing); myqdraw(drawing, myterminalpdf("/tmp/test")); myincludegraphics("height=3cm", "test"); * (find-sh0 "ls -lAF /tmp/test*") ** (find-pdf-page "/tmp/test.pdf") */ /* * Local Variables: * coding: utf-8-unix * End: */