这是我的代码
\begin{tikzpicture}[scale=1, font=\footnotesize, line join=round, line cap=round, >=stealth]
\def\a{1}
\def\b{0.4}
\def\h{3}
\pgfmathsetmacro\g{asin(-\b/\h)}
\pgfmathsetmacro\xo{\a *cos(\g)}
\pgfmathsetmacro\yo{\b *sin(\g)}
\draw[dashed] (\xo,\yo) arc (\g:180-\g:{\a} and {\b});
\draw (\xo,\yo) arc (\g:-180-\g:{\a} and {\b}) -- (-90:\h) --cycle;
\begin{scope}
\draw[dashed] (\xo,\yo) arc (\g:-180-\g:{\a});
\draw (\xo,\yo) arc (\g:180-\g:{\a});
\end{scope}
\end{tikzpicture}
答案1
以下是基本计算的起点:
\begin{document}
\begin{tikzpicture}
\def\R{5} % R is the radius of the sphere
\def\r{4.8} % r is the radius of the cone base
\pgfmathsetmacro\h{sqrt(\R*\R-\r*\r)}
\pgfmathsetmacro\a{asin(\r/\R)}
\pgfmathsetmacro\H{\r*tan(\a)}
%\draw[red,thick] (0,0) -- (-90+\a:\R);
\path (-\r,-\h) coordinate (S) --++ (\r,0) coordinate (K) --++ (\r,0) coordinate (T)
(0,0) coordinate (O) --++ (0,-\h-\H) coordinate (U);
% Wireframe
\draw (T) arc (-90+\a:270-\a:\R);
\draw (S) -- (U) -- (T)
(T) arc (0:-180:\r cm and 0.2*\r cm);
\draw [dashed] (S) -- (T)
(K) -- (U)
(T) arc (0:180:\r cm and 0.2*\r cm)
(S) arc (270-\a:270+\a:\R);
\end{tikzpicture}
\end{document}
编辑
回应 OP 在评论中的疑问,当圆锥底部的半径太小时,椭圆会太粗,无法反映 3D 视图的准确现实。然后可以更改椭圆的宽度来纠正此问题:
% Wireframe
\draw (T) arc (-90+\a:270-\a:\R);
\draw (S) -- (U) -- (T)
(T) arc (0:-180:\r cm and 0.1*\r cm);
\draw [dashed] (S) -- (T)
(K) -- (U)
(T) arc (0:180:\r cm and 0.1*\r cm)
(S) arc (270-\a:270+\a:\R);
答案2
你可以使用这个代码。我用的是3d工具来绘制它。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view=%
{phi=110,psi=0,theta=70},line join = round, line cap = round,c/.style={circle,fill,inner sep=1pt},
declare function={R=4;r=3.5;h= sqrt(R*R- r*r);a=asin(r/R);H=r*tan(a); d = h + H;}]
\path (0,0,0) coordinate (O)
(0,0,-h) coordinate (H)
(0,0,-d) coordinate (T);
\path (H) pic[3d/cone/inner/.style={save named path=cone,draw=none}]{3d/cone={r=r,h=-H}};
\path[save named path=sph,3d/screen coords] (O) circle[radius=R];
\tikzset{3d/draw ordered paths={cone,sph}}
\path foreach \p/\g in {O/90,H/0,T/-90}
{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\draw[3d/hidden] (T) --(O);
\end{tikzpicture}
\end{document}
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view=%
{phi=110,psi=0,theta=70},line join = round, line cap = round,c/.style={circle,fill,inner sep=1pt},
declare function={R=4;r=3.5;h= sqrt(R*R- r*r);a=asin(r/R);H=r*tan(a); d = h + H;}]
\path (0,0,0) coordinate (O)
(0,0,-h) coordinate (H)
(0,0,-d) coordinate (T);
\path (H)
pic[3d/cone/inner/.style={save named path=icone,draw=none},
3d/cone/outer/.append style={save named path=ocone},
]{3d/cone={r=r,h=-H}};
\path[save named path=sph,3d/screen coords] (O) circle[radius=R];
\tikzset{3d/draw ordered paths={icone,sph,ocone}}
\path foreach \p/\g in {O/90,H/0,T/-90}
{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\draw[3d/hidden] (T) --(O);
\end{tikzpicture}
\end{document}