Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://anggtwu.net/LUA/Tracinhos1.lua.html -- http://anggtwu.net/LUA/Tracinhos1.lua -- (find-angg "LUA/Tracinhos1.lua") -- Author: Eduardo Ochs <eduardoochs@gmail.com> -- -- (defun e () (interactive) (find-angg "LUA/Tracinhos1.lua")) -- Supersedes: -- (find-angg "LUA/Pict2e1-1.lua") -- «.Tracinhos» (to "Tracinhos") -- «.Tracinhos-test» (to "Tracinhos-test") require "Pict3" -- (find-angg "LUA/Pict3.lua") require "Piecewise2" -- (find-angg "LUA/Piecewise2.lua") local v = MiniV.fromab -- _____ _ _ -- |_ _| __ __ _ ___(_)_ __ | |__ ___ ___ -- | || '__/ _` |/ __| | '_ \| '_ \ / _ \/ __| -- | || | | (_| | (__| | | | | | | | (_) \__ \ -- |_||_| \__,_|\___|_|_| |_|_| |_|\___/|___/ -- -- «Tracinhos» (to ".Tracinhos") Tracinhos = Class { type = "Tracinhos", new = function (r) r = r or 0.2 return Tracinhos { r=r, p=Pict {} } end, from = function (r, f) return Tracinhos.new(r):setf(f):drawf() end, __index = { setf = function (tr, f) if type(f) == "string" then f = Code.ve("x,y => "..f) end tr.f = f return tr end, v = function (tr, Dy, Dx) Dx = Dx or 1 if Dx == 0 then if Dy == 0 then return nil end return v(0, tr.r) end local v0 = v(Dx, Dy) local v1 = v0 * (1 / v0:norm()) local v2 = v1 * tr.r return v2 end, tracinho = function (tr, xy, Dy, Dx) local vv = tr:v(Dy, Dx) if not vv then return tr end tr.p:addline(xy-vv, xy+vv) end, drawfxy0 = function (tr,x,y) return tr.f(x,y) end, drawfxy = function (tr,x,y) tr:tracinho(v(x,y), tr.f(x,y)) end, drawf = function (tr) for y=2,-2,-1 do for x=-2,2 do tr:drawfxy(x,y) end end return tr end, show0 = function (tr) return tr.p:pgat("pNc") end, show = function (tr) return tr.p:pgat("pNc"):show("") end, }, } -- «Tracinhos-test» (to ".Tracinhos-test") --[==[ ** (find-code-show2 "~/LATEX/Show2.tex") * (code-show2 "~/LATEX/Show2.tex") * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "Tracinhos1.lua" tr = Tracinhos.new(0.2) PictBounds.setbounds(v(-2,-2), v(2,2)) for y=2,-2,-1 do for x=-2,2 do tr:tracinho(v(x,y), -y, x) end end = tr.p:pgat("pN"):show("") * (etv) ** (find-code-show2 "~/LATEX/Show2.tex") * (code-show2 "~/LATEX/Show2.tex") * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "Tracinhos1.lua" PictBounds.setbounds(v(-2,-2), v(2,2)) tr = Tracinhos.from(0.2, "1,x") = Tracinhos.from(0.2, "1,x"):show0() = Tracinhos.from(0.2, "1,x"):show() * (etv) = Tracinhos.from(0.2, "-y,x"):show() * (etv) = Tracinhos.from(0.2, "-x,y"):show() * (etv) = Tracinhos.from(0.2, "x,y"):show() * (etv) = Tracinhos.from(0.2, "x+y,2"):show() * (etv) --]==] -- Local Variables: -- coding: utf-8-unix -- End: