|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; (find-angg "elisp/rpn.el")
;; (find-angg "elisp/geometria.el")
;; (find-angg "elisp/graficos.el")
;; (load "./rpn.el")
;; (load "./geometria.el")
;; (load "./graficos.el")
;; (start-process "plot" nil "wish" "./plot.tcl")
(defun op1->1 (f)
(poe (apply f (tira) args-extras)))
(defun op2->1 (f)
(let ((arg2_ (tira)) (arg1_ (tira)))
(poe (apply f arg1_ arg2_ args-extras))))
(defun op3->1 (f)
(let ((arg3_ (tira)) (arg2_ (tira)) (arg1_ (tira)))
(poe (apply f arg1_ arg2_ arg3_ args-extras))))
(defun op4->1 (f)
(let ((arg4_ (tira)) (arg3_ (tira)) (arg2_ (tira)) (arg1_ (tira)))
(poe (apply f arg1_ arg2_ arg3_ arg4_ args-extras))))
(defun op1->0 (f)
(apply f (tira) args-extras))
(defun op2->0 (f)
(let ((arg2_ (tira)) (arg1_ (tira)))
(apply f arg1_ arg2_ args-extras)))
(defun op3->0 (f)
(let ((arg3_ (tira)) (arg2_ (tira)) (arg1_ (tira)))
(apply f arg1_ arg2_ arg3_ args-extras)))
(defun op4->0 (f)
(let ((arg4_ (tira)) (arg3_ (tira)) (arg2_ (tira)) (arg1_ (tira)))
(apply f arg1_ arg2_ arg3_ arg4_ args-extras)))
(defun p_plot (p) (nn_plotponto (@x p) (@y p)))
(defun pp_plot (p1 p2) (nnnn_plotsegmento (@x p1) (@y p1) (@x p2) (@y p2)))
(defun pp_plot-> (p1 p2) (nnnn_plotseta (@x p1) (@y p1) (@x p2) (@y p2)))
(defun s_plot (s) (nnnn_plotsegmento (@x1 s) (@y1 s) (@x2 s) (@y2 s)))
(defun s_plot-> (s) (nnnn_plotseta (@x1 s) (@y1 s) (@x2 s) (@y2 s)))
(setq operacoes
'((+ . (poe (+ (tira) (tira))))
(* . (poe (* (tira) (tira))))
(- . (let ((arg2 (tira)) (arg1 (tira))) (poe (- arg1 arg2))))
(/ . (let ((arg2 (tira)) (arg1 (tira))) (poe (/ arg1 arg2))))
(sqrt . (poe (sqrt (tira))))
(-> . (set (car args-extras) (tira)))
(drop . (tira))
(dump . (plotstr "# %S\n" (tira)))
(mostra . (plotstr "# %S\n" (eval (car args-extras))))
(nn_ponto . (op2->1 'nn_ponto))
(nn_vetor . (op2->1 'nn_vetor))
(vv_+ . (op2->1 'vv_+))
(pv_+ . (op2->1 'pv_+))
(vn_* . (op2->1 'vn_*))
(pp_segmento . (op2->1 'pp_segmento))
(s_vetor . (op1->1 's_vetor))
(pp_-> . (op2->1 'pp_->))
(v_comprimento . (op1->1 'v_comprimento))
(pp_distancia . (op2->1 'pp_distancia))
(v_versor . (op1->1 'v_versor))
(s_reta . (op1->1 's_reta))
(pp_reta . (op2->1 'pp_reta))
(rr_cruzamento . (op2->1 'rr_cruzamento))
(p_plot . (op1->0 'p_plot))
(pp_plot . (op2->0 'pp_plot))
(pp_plot-> . (op2->0 'pp_plot->))
(s_plot . (op1->0 's_plot))
(s_plot-> . (op1->0 's_plot->))
(nnnn_eixos . (op4->0 'eixos))
;;
(ppp_mediana . (op3->1 'ppp_mediana))
(ppp_bissetriz . (op3->1 'ppp_bissetriz))
(ppp_plot-triangulo . (op3->0 'ppp_plot-triangulo))
(ppp_cruzamentomedianas . (op3->1 'ppp_cruzamentomedianas))
))
(defun ppp_bissetriz (A B C &optional nomesegmento plot)
(let (AA1> AA2> AA3> A1 A2 A3)
(calcula '(A B pp_-> (v_versor AA1>) drop
A C pp_-> (v_versor AA2>) drop
AA1> AA2> (vv_+ AA3>) drop
A AA1> (pv_+ A1) drop
A AA2> (pv_+ A2) drop
A AA3> (pv_+ A3) drop
))
(if plot
(calcula '(A1 p_plot
A2 p_plot
A3 p_plot
A A1 pp_plot->
A A2 pp_plot->
A1 A3 pp_plot->
A2 A3 pp_plot->
A A3 pp_plot->
)))
(pp_segmento A A3 nomesegmento)))
(defun ppp_mediana (A B C &optional nomesegmento plot123 plot4)
(let (A4)
(calcula `(A B C (ppp_bissetriz nil ,plot123) s_reta
B C pp_segmento s_reta
(rr_cruzamento A4) drop
))
(if plot4 (calcula '(A4 p_plot
A A4 pp_plot
)))
(pp_segmento A A4 nomesegmento)))
(defun ppp_cruzamentomedianas (A B C &optional nomecruzamento
plotA123 plotB123 plotC123
plot4)
(let (AA4 BB4 CC4)
(calcula `(A B C (ppp_mediana AA4 ,plotA123 ,plot4) drop
B A C (ppp_mediana BB4 ,plotB123 ,plot4) drop
C A B (ppp_mediana CC4 ,plotC123 ,plot4) drop
))
(rr_cruzamento (s_reta AA4) (s_reta BB4) nomecruzamento)))
(defun ppp_plot-triangulo (A B C)
(calcula '(A p_plot B p_plot C p_plot
A B pp_plot A C pp_plot B C pp_plot)))
;; Teste (2004jul04)
;; (find-fline "/tmp/1.tcl")
(progn
(setq pilha ())
(setq tclstring "")
(setq escala 20)
(calcula '(-1.5 -1.5 4.5 3.5 nnnn_eixos
0 3 (nn_ponto D) drop
4 3 (nn_ponto E) drop
4 0 (nn_ponto F) drop
D E F ppp_plot-triangulo
;; D E F (ppp_bissetriz plot)
D E F (ppp_mediana DD4 plot plot)
;; E D F (ppp_mediana EE4 nil plot)
(mostra pilha)
;; D E F (ppp_cruzamentomedianas nil nil nil nil plot) p_plot
))
(write-region tclstring nil "/tmp/1.tcl")
pilha)
(progn
(setq pilha ())
(setq tclstring "")
(setq escala 20)
(calcula '(;; -1 -1 6 6 nnnn_eixos
0 1 (nn_ponto A) p_plot drop
4 0 (nn_ponto B) p_plot drop
5 4 (nn_ponto C) p_plot drop
1 5 (nn_ponto D) p_plot drop
A B pp_plot B C pp_plot C D pp_plot D A pp_plot
))
(plotstr ".c create text %s -anchor n -text \"(0,1)\"\n" (tkxy (@x A) (@y A)))
(plotstr ".c create text %s -anchor n -text \"(4,0)\"\n" (tkxy (@x B) (@y B)))
(write-region tclstring nil "/tmp/1.tcl")
pilha)
;; (find-fline "/tmp/1.tcl")
;; (eev "cp /tmp/1.eps /home/edrx/eev-0.94/bissetriz.eps")
;; (eev "cd /tmp/; gv 1.eps")
;; (eqreduzida (pp_reta '(ponto 0 0) '(ponto 2 3)))