claudio” post=92321I castelli sono quelli del buon Ruffini
in questa prima versione ho badato a disegnarne uno semplice
ecco il codice
`
\documentclass[11pt]{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\tikzset{tondo/.style={draw,circle,minimum width=2.5em}};
\tikzset{notondo/.style={circle,minimum width=2.5em}};
\tikzset{freccia/.style={-triangle 90,very thick}};
\tikzstyle{etichetta}=[midway,fill=black!20]%A
\pgfmathsetmacro{\xa}{0};
\pgfmathsetmacro{\ya}{0};
%B
\pgfmathsetmacro{\xb}{4};
\pgfmathsetmacro{\yb}{\ya};
%C
\pgfmathsetmacro{\xc}{\xb};
\pgfmathsetmacro{\yc}{3};
%D
\pgfmathsetmacro{\xd}{\xa};
\pgfmathsetmacro{\yd}{\yc};
\pgfmathsetmacro{\deltac}{1.5};
\pgfmathsetmacro{\deltar}{1};
\draw(\xa-\deltar,\ya)–(\xb+\deltar,\yb);
\draw(\xb,\yb-\deltac)–(\xc,\yc+\deltac);
\draw(\xc+\deltar,\yc)–(\xd-\deltar,\yd);
\draw(\xd,\yd+\deltac)–(\xa,\ya-\deltac);\node[tondo] (A1) at (1,3.5) {$1$};
\node[tondo] (A2) at (3,3.5) {$2$};
\node[tondo] (AT) at (4.5,3.5) {$1$};\node[tondo] (D1) at (-0.5,0.5) {$-1$};
\node[tondo] (M2) at (3,0.5) {$-1$};
\node[tondo] (MR) at (4.5,0.5) {$-1$};\node[tondo] (B1) at (1,-1.2) {$1$};
\node[tondo] (B2) at (3,-1.2) {$1$};
\node[tondo] (R) at (4.5,-1.2) {$0$};\draw [freccia] (A1)–(B1);
\draw [freccia] (D1)–(B1) node[etichetta]{$*$};
\draw [freccia] (B1)–(M2) node[etichetta]{$=$};
\draw [freccia] (A2)–(M2)node[etichetta]{$+$};
\draw [freccia] (M2)–(B2)node[etichetta]{$=$};;
\draw [freccia] (D1)–(B2)node[etichetta]{$*$};;
\draw [freccia] (B2)–(MR)node[etichetta]{$=$};;
\draw [freccia] (AT)–(MR)node[etichetta]{$+$};;
\draw [freccia] (MR)–(R)node[etichetta]{$=$};;
\end{tikzpicture}
\end{document}
`in questa seconda versione ho cercato di generalizzare il codice in modo
da poterlo utilizzare con polinomi di grado superiore.`
\documentclass[11pt]{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\tikzset{tondo/.style={draw,circle,minimum width=2.5em}};
\tikzset{notondo/.style={circle,minimum width=2.5em}};
\tikzset{freccia/.style={-triangle 90,very thick}};
\tikzstyle{etichetta}=[midway,fill=black!20]\pgfmathsetmacro{\np}{2};
%A
\pgfmathsetmacro{\xa}{0};
\pgfmathsetmacro{\ya}{0};
%B
\pgfmathsetmacro{\xb}{\np*2};
\pgfmathsetmacro{\yb}{\ya};
%C
\pgfmathsetmacro{\xc}{\xb};
\pgfmathsetmacro{\yc}{3};
%D
\pgfmathsetmacro{\xd}{\xa};
\pgfmathsetmacro{\yd}{\yc};
%disegno righe castello
\pgfmathsetmacro{\extrac}{1.5};
\pgfmathsetmacro{\extrar}{1};
\draw(\xa-\extrar,\ya)–(\xb+\extrar,\yb);
\draw(\xb,\yb-\extrac)–(\xc,\yc+\extrac);
\draw(\xc+\extrar,\yc)–(\xd-\extrar,\yd);
\draw(\xd,\yd+\extrac)–(\xa,\ya-\extrac);
%aggiustamento punti prima riga
\pgfmathsetmacro{\deltaa}{3.5};
%posizionamento coefficienti in alto
\foreach \x/\co in{1/1,
3/2,
4.5/1}
\draw(\x,\deltaa) node[tondo] {\co};\pgfmathsetmacro{\deltam}{0.5};
%posizionamento coefficienti in mezzo
\foreach \x/\co in{-0.5/-1
,3/-1,
4.5/-1}
\draw(\x,\deltam) node[tondo] {\co};\pgfmathsetmacro{\deltab}{-1.2};
%posizionamento coefficienti in mezzo
\foreach \x/\co in{1/1
,3/1
,4.5/1}
\draw(\x,\deltab) node[tondo] {\co};
\draw [freccia] (1,\deltaa)–(1,\deltab);\end{tikzpicture}
\end{document}
`Tutto va bene finché non cerco di collegare
i punti con le frecce per indicare i passaggi
il perché è ovvio
nel primo esempio sono nodi nel secondo punti
e l’effetto estetico non è uguale
come rimediare ?
ciao
claudio
Si, nel secondo esempio colleghi usando coordinate sebbene i cerchi siano comunque dei nodi. Quello che devi fare, quindi, è trovare un sistema per dare un nome univoco ai nodi così da poter continuare a fare i collegamenti come nel primo disegno.
Ciao
Claudio