2

I need to draw a path leaving the origin at a sight angle and reaching a desired location. Here is my code.

\begin{tikzpicture}
\def\localDistance{5}
\def\localHeight{3}
\def\sightAngle{atan(\localHeight/\localDistance)}
\draw
    (0,0) to[out=\sightAngle,in=180]
        (\localDistance,\localHeight)  node[right]{Error message rises when I set out=\textbackslash sightAngle}
    ;
\end{tikzpicture}

I get the following error message

No shape named atan(3/localDistance is known.

My question is: what am I doing wrong here?

I saw a similar issue here but at the same time totally different. I tried those suggestions, but didn't work.

Brasil
  • 1,286

1 Answers1

4

Use \pgfmathsetmacro to get this work properly:

enter image description here

\documentclass[border=6pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\def\localDistance{5}
\def\localHeight{3}
\pgfmathsetmacro\sightAngle{atan(\localHeight/\localDistance)}
\draw
    (0,0) to[out=\sightAngle,in=180]
        (\localDistance,\localHeight)  node[right]{Error message rises when I set out=\textbackslash sightAngle}
    ;
\end{tikzpicture}
\end{document}
A.Ellett
  • 50,533