|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; Funções para plotar gráficos
;; 2004jun24
;; (find-angg "elisp/plot.tcl")
(require 'cl)
(setq origemx 200)
(setq origemy 200)
(setq escala 40)
(setq ticksize .075)
(defun tkxy (x y)
(format "%.1f %.1f" (+ origemx (* x escala))
(- origemy (* y escala))))
(setq tclstring "")
(defun plotstr (formatstr &rest rest)
(setq tclstring (concat tclstring (apply 'format formatstr rest))))
(defun nn_plotponto (x y)
(plotstr "ponto %s\n" (tkxy x y)))
(defun nnnn_plotsegmento (x1 y1 x2 y2)
(plotstr "segmento %s %s\n" (tkxy x1 y1) (tkxy x2 y2)))
(defun nnnn_plotsegmentoeixo (x1 y1 x2 y2)
(plotstr "segmento_eixo %s %s\n" (tkxy x1 y1) (tkxy x2 y2)))
(defun nnnn_plotseta (x1 y1 x2 y2)
(plotstr "seta %s %s\n" (tkxy x1 y1) (tkxy x2 y2)))
(defun eixos (minx miny maxx maxy)
(nnnn_plotsegmentoeixo minx 0 maxx 0)
(nnnn_plotsegmentoeixo 0 miny 0 maxy)
(loop for x from 0 downto minx do
(nnnn_plotsegmentoeixo x (- ticksize) x ticksize))
(loop for x from 0 to maxx do
(nnnn_plotsegmentoeixo x (- ticksize) x ticksize))
(loop for y from 0 downto miny do
(nnnn_plotsegmentoeixo (- ticksize) y ticksize y))
(loop for y from 0 to maxy do
(nnnn_plotsegmentoeixo (- ticksize) y ticksize y))
)
(defun plot_t_xy (mint maxt step f)
(let (ponto pontoanterior)
(loop for tt from mint to maxt by step do
(setq pontoanterior ponto)
(setq ponto (funcall f tt))
(if (and pontoanterior ponto) (pp_plot pontoanterior ponto))
(if ponto (p_plot ponto)))))
'
(progn
(setq tclstring "")
(eixos -6.5 -2.5 6.5 2.5)
;; (eixos minx miny maxx maxy)
(plot_t_xy -6.4 6.4 .1 (lambda (x) (nn_ponto x (sin x))))
(write-region tclstring nil "/tmp/1.tcl")
tclstring)
'
(progn
(setq tclstring "")
(nn_plotponto 0 0)
(nn_plotponto 1 0)
(nn_plotponto 2 1)
(nnnn_plotsegmento 0 0 1 0)
(nnnn_plotseta 1 0 2 1)
(eixos -2.5 -2.5 4.5 4.5)
;; (eixos minx miny maxx maxy)
(write-region tclstring nil "/tmp/1.tcl")
tclstring)
;; (eev "wish ~/elisp/plot.tcl &")