如何使用 TikZ 绘制一个带孔的半透明灰色球体壳?

如何使用 TikZ 绘制一个带孔的半透明灰色球体壳?

我需要表示一个半径为 R 的灰色球体,其中有一个由角度 alpha 的圆锥体定义的空心圆,我有圆锥部分,但我不知道如何绘制球体......

我有这个:

\documentclass[10pt, letterpaper]{article}%tipo
\usepackage{amsmath, amsthm, amssymb}
    \usepackage{etex, tikz, tikz-3dplot, xcolor}
        \usetikzlibrary{
                    arrows, 
                    fadings,
                    calc}
\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
        \definecolor{miverde}{RGB}{44,162,67}
\begin{document}
\begin{center}\pgfmathsetmacro{\phivec}{135}
\tdplotsetmaincoords{70}{\phivec}
\tdplotsetthetaplanecoords{\phivec}
\begin{tikzpicture}[tdplot_main_coords,scale=4]
\pgfmathsetmacro{\Rvec}{1.4}
\pgfmathsetmacro{\alphavec}{20}
\pgfmathsetmacro{\dc}{cos(\phivec)}
\pgfmathsetmacro{\ds}{sin(\phivec)}
\pgfmathsetmacro{\dd}{sin(\alphavec)}
\pgfmathsetmacro{\df}{cos(\alphavec)}
\pgfmathsetmacro{\rvec}{\Rvec*\dd}
%
\draw[dashed](0,0,0)--(\rvec*\dc,\rvec*\ds,\Rvec*\df);
\draw[dashed](0,0,0)--(-\rvec*\dc,-\rvec*\ds,\Rvec*\df);
\draw[miverde] (-\rvec,0,\Rvec*\df) arc (180:360:\rvec);
%
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{.7}{0}%
{\alphavec}{anchor=south}{$\alpha$}
%====Ejes====
\draw[red,line width=0.7pt,-latex](0,0,0)--(2,0,0)node[left]{$x$};
\draw[red,line width=0.7pt,-latex](0,0,0)--(0,2,0)node[right]{$y$};
\draw[red,line width=0.7pt,-latex](0,0,0)--(0,0,2)node[left]{$z$};
\draw[miverde] (\rvec,0,\Rvec*\df) arc (0:180:\rvec);
\end{tikzpicture}
\end{center}
\end{document}

它的生产方式是: 在此处输入图片描述

我希望它看起来: 在此处输入图片描述 但以原点为中心,无线电\Rvec和灰色,提前致谢。

答案1

我不太明白最终结果应该是什么样子,所以有点随意。轴和刻度标签可以稍后调整,但在调整内容时请保持样本数量较低。否则等待编译真的不是一件有趣的事情。

基本上,我尝试先画一个半球,然后画一个圆锥体,最后画剩下的部分,这样 z 顺序就不会破坏气氛。Asymptote/MetaPost 的人无论如何都会把它搞砸 :)

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={35}{20},
axis lines=center,
axis on top,axis equal,
xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
domain=0:0.8,
y domain=0:2*pi,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=-1,
samples=20,
samples y=20,
z buffer=sort,
colormap/blackwhite,point meta rel=per plot
]
\addplot3[surf,domain=-1:0.8,y domain=0:pi, colormap/hot,mesh/interior colormap name=blackwhite,opacity=0.8]({sqrt(1-x^2)*cos(deg(y))},{sqrt(1-x^2)*sin(deg(y))},x);
\addplot3[surf,colormap/blackwhite,mesh/interior colormap name=hot]({6/8*x*cos(deg(y))},{6/8*x*sin(deg(y))},{x});
\addplot3[surf,colormap/hot,domain=-1:0.8,opacity=0.8,y domain=-pi:-pi/2.5,mesh/interior colormap name=blackwhite]({sqrt(1-x^2)*cos(deg(y))},{sqrt(1-x^2)*sin(deg(y))},x);
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容