我想在 TikZ 中绘制以下定义球面坐标的图像。
我目前的努力成果如下。感谢您的帮助!
\documentclass[border=5pt]{standalone}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{75}{125}
\pgfmathsetmacro{\R}{2}
\pgfmathsetmacro{\r}{1.85}
\begin{tikzpicture}[tdplot_main_coords]
\draw[gray, thick, -Stealth] (-2,0,0) -- (5,0,0) node[black, left] {$x$};
\draw[gray, thick, -Stealth] (0,-2,0) -- (0,4,0) node[black, right] {$y$};
\draw[gray, thick, -Stealth] (0,0,-2) -- (0,0,4) node[black, left] {$z$};
\shade[ball color=brown, tdplot_screen_coords, opacity=0.6] (0,0,0) circle [radius=\R];
\fill [brown!67!black, canvas is xz plane at y=0, opacity=0.6] (\R,0) arc [start angle=0, end angle=90, radius=\R] -- (0,\r) arc [start angle=90, end angle=0, radius=\r] -- cycle;
\fill [brown!50, canvas is xz plane at y=0, opacity=0.6] (0,0) -- (\r,0) arc [start angle=0, end angle=90, radius=\r] -- cycle;
\fill [brown!67!black, canvas is xy plane at z=0, opacity=0.6] (\R,0) arc [start angle=0, end angle=90, radius=\R] -- (0,\r) arc [start angle=90, end angle=0, radius=\r] -- cycle;
\fill [brown!50, canvas is xy plane at z=0, opacity=0.6] (0,0) -- (\r,0) arc [start angle=0, end angle=90, radius=\r] -- cycle;
\fill [brown!67!black, canvas is yz plane at x=0, opacity=0.6] (\R,0) arc [start angle=0, end angle=90, radius=\R] -- (0,\r) arc [start angle=90, end angle=0, radius=\r] -- cycle;
\fill [brown!50, canvas is yz plane at x=0, opacity=0.6] (0,0) -- (\r,0) arc [start angle=0, end angle=90, radius=\r] -- cycle;
\fill [blue!67, opacity=0.6] (0,0,-3) -- ({-3*(cos(15))},{-3*(sin(15)},-4) -- ({-3*(cos(15))},{-3*(sin(15))},3) -- (0,0,3) -- cycle;
\draw [thick, -Latex, canvas is xy plane at z=0] (0.5,0) arc [start angle=0, end angle=75, radius=0.5];
\node at (1,0.25,-0.25) {$\theta_0$};
\end{tikzpicture}
\end{document}
答案1
这肯定是一个棘手的问题。主要的困难在于圆锥母线、平面椭圆与球面的切点,以及可见和不可见的顺序。在我的解决方案中,我使用了等距轴,以便于计算,但仍然有很多三角学知识。
这是我做的:
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{3d,calc}
\tikzset
{%
cone_inside/.style={fill=gray!40,,fill opacity=0.75},
cone_outside/.style={fill=gray!20,fill opacity=0.75},
sphere_inside/.style={fill=red!40},
sphere_outside/.style={fill=red!20},
plane/.style={fill=green!20,fill opacity=0.75}
}
\def\sr{2} % sphere radius
\def\ch{3.75} % cone height
\def\ph{30} % phi angle
\def\th{80} % theta angle, 45<th<90
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\pgfmathsetmacro\cr{\ch*tan(\ph)} % cone radius
\pgfmathsetmacro\cg{\ch/cos(\ph)} % cone generatrix
\pgfmathsetmacro\ih{\sr*cos(\ph)} % intersection circle (sphere-cone) height
\pgfmathsetmacro\ir{\sr*sin(\ph)} % intersection circle (sphere-cone) radius
\pgfmathsetmacro\gs{sqrt((2*\ch*\ch-\cr*\cr)/(3*\cr*\cr))} % generatrix slope
\pgfmathsetmacro\xt{sqrt(6)*\gs*\ch/(1+3*\gs*\gs)} % tangent point x
\pgfmathsetmacro\yt{\gs*\xt} % tangent point y
\pgfmathsetmacro\aa{(\ch*\zz-\yt)/\xy/2-\xt/\xx/2} % coordinate x in xy plane
\pgfmathsetmacro\bb{(\ch*\zz-\yt)/\xy/2+\xt/\xx/2} % coordinate y in xy plane
\pgfmathsetmacro\at{atan(\bb/\aa)+180} % angle to the tangent point
% ellipse in the greeen plane
\pgfmathsetmacro\xq{(sin(\th)+cos(\th))*\xx} % Q(xq,yq), point in the minor axis (2d coordinates)
\pgfmathsetmacro\yq{(sin(\th)-cos(\th))*\xy}
\pgfmathsetmacro\aq{-atan(\xq/\yq)} % angle between OQ and the horizontal (2d)
\pgfmathsetmacro\xr{sqrt(2)*\xq)/(-1+tan(\th))} % R(xr,yr,zr), point Q in isometric coordinates (3d)
\pgfmathsetmacro\yr{\xr*tan(\th)}
\pgfmathsetmacro\zr{(\xr+\yr+\yq*sqrt(6))/2}
\pgfmathsetmacro\ar{90-atan(\zr/sqrt(\xr*\xr+\yr*\yr))} % angle between OQ and the horizontal (3d)
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}]
% sphere
\begin{scope}
\draw[sphere_outside] (0,0) circle (\sr cm);
\end{scope}
% cone (inside)
\draw[cone_inside] ($(90-\at:\ir)+(0,0,\ih)$) arc (90-\at:-360+\at:\ir) --
($(-360+\at:\cr)+(0,0,\ch)$) arc (-360+\at:90-\at:\cr) -- cycle;
\begin{scope}[canvas is xy plane at z=\ch]
\draw[] (0,0) circle (\cr);
\end{scope}
% cone (ouside west)
\draw[cone_outside] ($(\th:\ir)+(0,0,\ih)$) arc (\th:\at:\ir) --
($(\at:\cr)+(0,0,\ch)$) arc (\at:\th:\cr) -- cycle;
% y axis
\draw[thick,-latex] (0,\sr,0) -- (0,\sr+2,0) node[right] {$y$};
% sphere (inside)
\draw[sphere_inside]
{[canvas is xy plane at z=0] (\th:\sr) arc (\th:0:\sr)}
{[canvas is xz plane at y=0] arc (0:90:\sr)}
{[rotate around z=\th, canvas is xz plane at y=0] arc(90:0:\sr)};
\begin{scope}[canvas is xy plane at z=0]
\draw[blue,-latex] (0.5*\sr,0) arc (0:\th:0.5*\sr)
node[midway,below] {$\theta_0$};
\end{scope}
% plane
\draw[plane]
{[rotate around z=\th, canvas is xz plane at y=0]
(0,\ch) -- (0,0) -- (\sr,0) arc (0:-\ar:\sr)}
{[x={(1 cm, 0 cm)}, y={(0 cm, 1cm)}] arc (\aq:-90:\sr)}
{[rotate around z=\th, canvas is xz plane at y=0] --
(0,-0.75*\ch) -- (\ch,-0.75*\ch) -- (\ch,\ch) -- cycle};
\begin{scope}[rotate around z=\th, canvas is xz plane at y=0]
\draw[blue,-latex] (0,1.5*\sr) arc (90:90-\ph:1.5*\sr)
node[midway,above] {$\varphi_0$};
\end{scope}
% z axis
\draw[thick,-latex] (0,0,0) -- (0,0,\ch+1) node[left] {$z$};
% cone (ouside east)
\draw[cone_outside] (0,0,0) -- ($(\ir,0)+(0,0,\ih)$) arc (0:90-\at:\ir) --
($(90-\at:\cr)+(0,0,\ch)$) arc (90-\at:\th:\cr) -- cycle;
% x axis
\draw[thick,-latex] (0,0,0) -- (\sr+2,0,0) node[left] {$x$};
% red lines in the plane
\begin{scope}[rotate around z=\th, canvas is xz plane at y=0]
\draw[thick,red] (90-\ph:\cg) -- (0,0) -- (\ch,0);
\end{scope}
\fill[red] ($(\th:\ir)+(0,0,\ih)$) circle (0.35mm);
\end{tikzpicture}
\end{document}