Sorry to ask an extremely "entry-level" question, but after googling to get a description of how to do conditional logic in TikZ, I don't see a straight and simple answer. I see a bunch of very complicated examples where the point is not to explain the use of conditional logic, but to accomplish some specific task, and I can't quite sort through what is strictly necessary to get a basic if-then-else.
I am trying to do a double-loop over some floats, and want to skip the particular case where both \i and \j are zero. Here is a very pared down example:
\foreach \i in {-3,...,3} {
\foreach \j in {-3,...,3} {
\node at (\i,\j) {\i+\j};
}
}
I have seen examples of using \ifnum but none of them involve performing a boolean computation. Here I need something like
\foreach \i in {-3,...,3} {
\foreach \j in {-3,...,3} {
\ifnum {\i!=0 \AND \j!=0} {\node at (\i,\j) {\i+\j};};
}
}
But I can't find documentation on the correct way to write negations, conjunctions, and so on. More generally, if anyone knows a reference for this sort of intro-level documentation for programming in TikZ, I'd appreciate it!
If it's valuable, here is a more complete example of what I'm trying to do. The following code throws an error, presumably because of the case when \i and \j are both zero.
\begin{tikzpicture}
\foreach \i in {-3,-2.5,...,3} {
\foreach \j in {-3,-2.5,...,3} {
\pgfmathsetmacro \d {2*sqrt((\i)^2+(\j)^2)};
\draw[->] ({\i},{\j}) -- ({\i - \i/\d}, {\j-\j/\d});
};
};
\end{tikzpicture}

nodeand not\node). With lowlevel\ifnuma logical AND isn't trivial. But there are other ways. – Qrrbrbirlbel Jun 27 '23 at 16:47\dis now a floating point number, the low-level solution would be to\unless\ifdim\d pt=0pt \draw … ; \fi. (No;after the body of a loop, by the way.) – Qrrbrbirlbel Jun 27 '23 at 16:53\unless ...code worked, so if you make that the answer, I can accept it! – Addem Jun 27 '23 at 17:00