Re: if then multipli

#80034
claudio
Partecipante
    Up
    0
    Down
    ::

    egreg9″ post=79222

    ho un problema con questi if annidati
    in pratica la label T_5
    mi appare due volte
    ne vedete il motivo?

    No, mi sono perso nell’annidamento. 🙂

    `\newcommand{\stampa}[3]{%
    \ifcase#1\relax\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above] {$#3$};\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above right] {$#3$};\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above left] {$#3$};\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[below] {$#3$};\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[below right] {$#3$};\or
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[below left] {$#3$};%
    \fi
    }`
    Quando ci vuole ci vuole. 🙂

    Ciao
    Enrico

    grazie Enrico
    effettivamente troppe graffe
    Ma è la gestione del condizionale in se che è interessante
    cercando qua e la ho trovato molti pacchetti che hanno in comune solo le graffe
    dove trovare un punto fisso sull’argomento?
    comunque mancava una graffa

    `
    \documentclass[12pt,a4paper]{article}
    \usepackage{graphicx}
    \usepackage{amsmath,amssymb}
    \usepackage{tikz}
    \usetikzlibrary{calc}
    \usetikzlibrary{hobby}
    \usetikzlibrary{decorations}
    \usetikzlibrary{shapes,arrows,trees,positioning,through,intersections}
    \usetikzlibrary{shapes.gates.logic.US,shapes.gates.logic.IEC}
    \usepackage{xifthen}

    \newcommand{\stampa}[3]{
    \ifthenelse{#1=1}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above] {$#3$};
    }
    {
    \ifthenelse{#1=2}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above left] {$#3$};
    }
    {
    \ifthenelse{#1=3}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above right] {$#3$};
    }
    {
    \ifthenelse{#1=4}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[below] {$#3$};
    }
    {
    \ifthenelse{#1=5}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[below left] {$#3$};
    }
    {
    \ifthenelse{#1=6}
    {
    \draw(0,0)–(\raggio,{\raggio*tan(#2)})node[above right] {$#3$};
    }
    {

    }
    }
    }
    }
    }
    }
    }

    \begin{document}

    \begin{tikzpicture}[>=triangle 45,scale=0.8]
    % draw the coordinates

    \pgfmathsetmacro{\raggio}{4};
    \pgfmathsetmacro{\mraggio}{\raggio/3};
    \pgfmathsetmacro{\qraggio}{\raggio/5};
    \pgfmathsetmacro{\sraggio}{1.9*\raggio};
    % draw the unit circle
    \draw[->] (0,-\raggio-\mraggio) — (0,\raggio+\mraggio+0.5) node[above,fill=white] {$y$};
    \draw[->] (-\raggio-\mraggio,0) — (\raggio+\mraggio,0) node[right,fill=white] {$x$};
    \draw[thick] (0,0) circle(\raggio);
    \draw (\raggio,-\raggio-\mraggio) — (\raggio,\raggio+\mraggio+0.5);
    \node(OO)at(0,0) [label= below right:$O$] {};

    \foreach \x/\z /\y in {
    0/1/ T_1,
    40/2/T_2,
    140/3/T_3,
    180/4/T_4,
    210/5/T_5,
    340/6/T_6
    }
    \stampa{\z}{\x}{\y};
    \end{tikzpicture}

    \end{document}

    `

    ciao e grazie
    claudio

    Go to top