定义新的数学函数

定义新的数学函数

我想使用a中的一个角度(比如说 )tikzpicture,它是根据其他参数计算出来的:

\def\d{1}
\def\D{2}
\def\H{5}

a=90+0.5*asin(2(\D-\d)/\H)

a然后我在环境中使用这个角度tikzpicture

\begin{tikzpicture}

  \coordinate (c1) at (0,0);

  \coordinate (c2) at ($(c1)+(\H,0)$);

  \draw (c1) circle (\d/2);

  \draw (c2) circle (\D/2);

  \draw ($(c1)+(\d/2:a)$) to ($(c2)+(\D/2:a)$);

\end{tikzpicture}

我该如何定义这个a

答案1

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc}
\begin{document}

\def\d{1}
\def\D{2}
\def\H{5}

\begin{tikzpicture}
  \pgfmathsetmacro{\a}{90+0.5*asin(2*(\D-\d)/\H)}
  \coordinate (c1) at (0,0);
  \coordinate (c2) at ($(c1)+(\H,0)$);
  \draw (c1) circle (\d/2);
  \draw (c2) circle (\D/2);
  \draw ($(c1)+(\d/2:\a)$) to ($(c2)+(\D/2:\a)$);
\end{tikzpicture}

\end{document}

相关内容