我正在尝试绘制四面体的球面DABC
。我的代码
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{100}
\begin{tikzpicture} [tdplot_main_coords]
\path
(0,0,0) coordinate (D)
(3,0,0) coordinate (B)
(0,6,0) coordinate (C)
(0,0,9) coordinate (A)
(1,1,1) coordinate (I)
;
\fill (D) circle (1.5pt) node [right] {$D$};
\fill (A) circle (1.5pt) node [above] {$A$};
\fill (B) circle (1.5pt) node [left] {$A$};
\fill (C) circle (1.5pt) node [right] {$C$};
\fill (I) circle (1.5pt) node [right] {$I$};
\draw[dashed,red] (I) circle[radius = 1];
\draw (C) -- (A) -- (B) -- cycle;
\draw[dashed] (D) -- (C) (D) --(A) (D) -- (B);
\end{tikzpicture}
\end{document}
我有
我无法得到球体的正确结果。我的问题:
- 我怎样才能得到正确的结果;
- 有没有办法像我的代码一样不使用中心
I
和半径来绘制球体?R = 1
答案1
我从中复制了部分代码这里。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=110,theta=70},line cap=butt,
line join=round,c/.style={circle,fill,inner sep=1pt},declare function={a=3;b=6;c=9;}]
\path
(0,0,0) coordinate (D)
(a,0,0) coordinate (A)
(0,b,0) coordinate (B)
(0,0,c) coordinate (C);
\tikzset{3d/plane through=(A) and (B) and (C) named pABC}
\path [3d/insphere center] coordinate (I)
[3d/project={(I) on pABC}] coordinate (I');
\pgfmathsetmacro{\myr}{tddistance("(I)","(I')")}
\shade[3d/screen coords,ball color=green, opacity=0.8]
(I) circle [radius=\myr];
\draw[3d/hidden] (D) -- (A) (D) --(B) (D) --(C);
\draw[3d/visible] (A) --(B) --(C) -- cycle;
\path foreach \p/\g in {A/-90,D/-90,B/-30,C/90,I/0}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}