根据答案如何使用 TikZ 或 PSTricks 绘制 3D、三边 5-7-9 三角形?,我尝试使用a=10;b=10;c=10
或更大,但尺寸太大。我的代码。
\documentclass[12pt, border = 1mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{60}
\begin{tikzpicture}[tdplot_main_coords,scale=1,tdplot_main_coords,declare function={a=10;b=10;c=10;R= 1/2*sqrt((a + b - c)* (a - b + c) *(-a + b + c)/(a + b + c));%
}]
\coordinate (A) at (0,0,0);
\coordinate (B) at (c,0,0);
\coordinate (C) at ({(pow(b,2) + pow(c,2) - pow(a,2))/(2*c)},{sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c)},0);
\coordinate (I) at ({1/2 *(-a + b + c)},
{ 1/2*sqrt(((a + b - c)* (a - b + c)* (-a + b + c))/(a + b + c))});
\draw[red,dashed,thick] (I) circle[radius= R];
\foreach \p in {A,B,C,I}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {A/180,C/0,B/-90}
\path (\p)+(\g:3mm) node{$\p$};
\draw[thick] (A) -- (B) -- (C) --cycle ;
\end{tikzpicture}
\end{document}
答案1
只需使用fpu
。我建议在本地使用它,例如
\begin{scope}[/pgf/fpu,/pgf/fpu/output format=fixed]
\coordinate (C) at ({(pow(b,2) + pow(c,2) - pow(a,2))/(2*c)},{sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c)},0);
\end{scope}
因为有些路径构造不适用于fpu
。
\documentclass[12pt, border = 1mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{fpu}
\begin{document}
\tdplotsetmaincoords{60}{60}
\begin{tikzpicture}[tdplot_main_coords,scale=1,tdplot_main_coords,declare function={a=10;b=10;c=10;R= 1/2*sqrt((a + b - c)* (a - b + c) *(-a + b + c)/(a + b + c));%
}]
\coordinate (A) at (0,0,0);
\coordinate (B) at (c,0,0);
\begin{scope}[/pgf/fpu,/pgf/fpu/output format=fixed]
\coordinate (C) at ({(pow(b,2) + pow(c,2) - pow(a,2))/(2*c)},{sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c)},0);
\end{scope}
\coordinate (I) at ({1/2 *(-a + b + c)},
{ 1/2*sqrt(((a + b - c)* (a - b + c)* (-a + b + c))/(a + b + c))});
\draw[red,dashed,thick] (I) circle[radius= R];
\foreach \p in {A,B,C,I}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {A/180,C/0,B/-90}
\path (\p)+(\g:3mm) node{$\p$};
\draw[thick] (A) -- (B) -- (C) --cycle ;
\end{tikzpicture}
\end{document}