[Tex/LaTex] Defining a function inside tikz enviroment


I would like to define a simple function inside tikz environment to help me drawing a plane. I found this thread, but I could not reproduce the proposed solution to fulfill my needs. Example code is:


declare function = {
plane(\x, \y) = - \x - \y + 3;

\draw[blue]  (0,0,{plane(0,0)});


Is it possible to use declare function in the attempt way? If so, how can I do this?

ps.: I would not like to use pgfplot for this! 🙂

Best Answer

Note the variables with no whitespaces in the definition.

\begin{tikzpicture}[declare function = {plane(\x,\y) = - \x - \y + 3;}]
\draw[blue]  (1,1) -- (0,0,{plane(0,0)});
\node at (0,0,3) {0,0,3};

enter image description here

Make your peace with the excessive whitespace usage :)