我正在尝试仅使用 来重现一个图形tikz
。我已经使用 制作了该图形Inkscape
,但我想知道我是否可以在 Latex 中完全完成它。
这是目标数字:
在一些贡献者的帮助下这里通过运行此代码,我能够重现图形的大线条:
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\tikzset{hemisphere/.style={#1,shading=ball,ball color=#1,fill opacity=0.75}}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{60}{110}
\usetikzlibrary{3d,perspective}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[isometric view,rotate around z=-90,line cap=round,line join=round]
% some dimensions
\pgfmathsetmacro\r{1} % radius
\pgfmathsetmacro\d{1.9} % distance between centers
\pgfmathsetmacro\a{acos(\d/(2*\r)} % angle
\pgfmathsetmacro\jr{sqrt(\r*\r-0.25*\d*\d)} % join radius
% x-axis and centers
\draw[canvas is xy plane at z=0,scale=1.5,fill=gray!7.5] (-\r,-\r) rectangle (\d+\r,\r);
\draw[-latex] (0,0) -- (3.5*\r,0) node[right] {$x$};
\draw[dashed,-latex] (0,0) -- (0,2.5*\r) node[right] {$y$};
\draw[-latex] (0,0) -- (-2,2*\r)node[right] {$z$} {[canvas is yz plane at x=0]};
\foreach\i in {0,1}
\fill (\i*\d,0) circle (0.2mm);
% left hemisphere
\draw[black,thin] (225:\r) arc (225:45:\r);
\draw[hemisphere=blue,scale = 1] (225:\r) arc (225:360-\a:\r)
{[canvas is yz plane at x=0.5*\d] arc (180:0:\jr)} arc (\a:45:\r) arc (0:180:\r cm);
% right hemisphere
\draw[black,thin] (\d,0) ++ (225:\r) arc (225:180+\a:\r)
{[canvas is yz plane at x=0.5*\d] arc (180:0:\jr)} arc (180-\a:45:\r);
\draw[hemisphere=green] (\d,0) ++ (225:\r) arc (225:405:\r) arc (0:180:\r cm);
\draw[dashed,black,thin]{[canvas is yz plane at x=1.8] (0.05,0) ++ (180:0.95) arc (180:0:0.95)};
\draw[stealth-stealth,red,ultra thin] (1.9,0,0) -- (1.3,1.05,0.3)node[below right,pos = 0.5,scale = 0.3,red] {$a$} {[canvas is yz plane at x=1.8]};
\draw[stealth-stealth,red,ultra thin] (1,0,0) -- (1,0,0.35)node[below right,pos = 0.85,scale = 0.3,red] {$h_0$} {[canvas is yz plane at x=0.5*\d]};
\draw[-latex] (0,0,1.223*\r) -- (-2,2*\r) {[canvas is yz plane at x=0]};
\end{tikzpicture}
\end{figure}
\end{document}
您可能会注意到这有点相似,但我的问题是:是否可以绘制非完全球形的东西?更像是球形帽而不是完整的半球形?我尝试过调整平面的位置,xy
但我认为问题出在包装上\tikzset{hemisphere}
如能得到任何帮助/建议我将非常感激!
先感谢您,
此致。
更新 :
我尝试按照评论中建议的步骤进行操作这个帖子但没能正确完成。我知道我必须删除\draw[hemisphere..]
并用另一行替换它。我的尝试是这样的,但根本不起作用:
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\tikzset{hemisphere/.style={#1,shading=ball,ball color=#1,fill opacity=0.75}}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{60}{110}
\usetikzlibrary{3d,perspective}
\usetikzlibrary{shadings}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[isometric view,rotate around z=-90,line cap=round,line join=round]
% some dimensions
\pgfmathsetmacro\r{1} % radius
\pgfmathsetmacro\d{1.9} % distance between centers
\pgfmathsetmacro\a{acos(\d/(2*\r)} % angle
\pgfmathsetmacro\jr{sqrt(\r*\r-0.25*\d*\d)} % join radius
% x-axis and centers
\draw[canvas is xy plane at z=0,scale=1.5,fill=gray!7.5] (-\r,-\r) rectangle (\d+\r,\r);
\draw[-latex] (0,0) -- (3.5*\r,0) node[right] {$x$};
\draw[dashed,-latex] (0,0) -- (0,2.5*\r) node[right] {$y$};
\draw[-latex] (0,0) -- (-2,2*\r)node[right] {$z$} {[canvas is yz plane at x=0]};
\foreach\i in {0,1}
\fill (\i*\d,0) circle (0.2mm);
% left hemisphere
\draw[black,thin] (225:\r) arc (225:45:\r);
\shade[ball color=green!50!blue] (0,0) ++ (225:\r) arc (225:0:\r) -- cycle;
% right hemisphere
\draw[black,thin] (\d,0) ++ (225:\r) arc (225:180+\a:\r)
{[canvas is yz plane at x=0.5*\d] arc (180:0:\jr)} arc (180-\a:45:\r);
\shade[ball color=green!50!blue] (\d+\r,0) arc (0:180:\r) -- cycle;
\draw[dashed,black,thin]{[canvas is yz plane at x=1.8] (0.05,0) ++ (180:0.95) arc (180:0:0.95)};
\draw[stealth-stealth,red,ultra thin] (1.9,0,0) -- (1.3,1.05,0.3) node[below right,pos=0.5,scale=0.3,red] {$a$} {[canvas is yz plane at x=1.8]};
\draw[stealth-stealth,red,ultra thin] (1,0,0) -- (1,0,0.35) node[below right,pos=0.85,scale=0.3,red] {$h_0$} {[canvas is yz plane at x=0.5*\d]};
\draw[-latex] (0,0,1.223*\r) -- (-2,2*\r) {[canvas is yz plane at x=0]};
\end{tikzpicture}
\end{figure}
\end{document}