TikZ 交叉点和不透明度

TikZ 交叉点和不透明度

我正在尝试在这里重新创建这幅图像,以便在 TikZ 中练习自己(我是新手):

我现在有的是:

我遇到的问题是,我希望底部圆弧延伸到刚好碰到水平圆弧(xy 平面)(见红色圆圈)。我遇到的第二个问题是,我想更改底部两个圆弧相交处的不透明度(见红色箭头和蓝线)。有谁能帮我吗?我是 TikZ 新手。谢谢!

\documentclass{article}
\usepackage{tikz}  %TikZ is required for this to work.  Make sure this exists before the next line
\usepackage{tikz-3dplot}
\usepackage[active,tightpage]{preview}  %generates a tightly fitting border around the work
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{2mm}

\def\radius{6}
\def\Alpha{20}
\def\Beta{20}
\def\Gamma{20}

\begin{document}

\tdplotsetmaincoords{70}{150}

\begin{tikzpicture}[tdplot_main_coords]
% Axis: x, y, z
\tdplotsetrotatedcoords{0}{0}{0}
\draw[very thick,tdplot_rotated_coords,-o,shorten >=-3pt] (0,0,0) -- (\radius,0,0) node[anchor=north east]{$x$};
\draw[very thick,tdplot_rotated_coords,-o,shorten >=-3pt] (0,0,0) -- (0,\radius,0) node[anchor=north west]{$y$};
\draw[very thick,tdplot_rotated_coords,-o,shorten >=-3pt] (0,0,0) -- (0,0,\radius) node[anchor=south]{$z=z'$};

% Axis: x', y', z'
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw[thick,tdplot_rotated_coords,-] (0,0,0) -- (\radius,0,0) node[anchor=north east]{$x'$};

% Axis: x'', y'', z''
\tdplotsetrotatedcoords{\Alpha}{\Beta}{0}
\draw[thick,tdplot_rotated_coords] (0,0,0) -- (\radius,0,0) node[anchor=north east]{$x''$};
\draw[thick,tdplot_rotated_coords] (0,0,0) -- (0,\radius,0) node[anchor=west]{$y'=y''$};
\draw[tdplot_rotated_coords] (0,-\radius,0) -- (0,\radius,0);

% Axis: X, Y, Z
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\draw[very thick,tdplot_rotated_coords,-*,shorten >=-3pt] (0,0,0) -- (\radius,0,0) node[anchor=north east]{$X$};
\draw[very thick,tdplot_rotated_coords,-*,shorten >=-3pt] (0,0,0) -- (0,\radius,0) node[anchor=west]{$Y$};
\draw[very thick,tdplot_rotated_coords,-*,shorten >=-3pt] (0,0,0) -- (0,0,\radius) node[anchor=east]{$z''=Z$};

% Circles
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw [tdplot_rotated_coords,domain=-90:90] plot ({\radius*cos(\x)}, {\radius*sin(\x)});
\tdplotsetrotatedcoords{\Alpha}{90}{0}
\draw [tdplot_rotated_coords,domain=90:270] plot ({\radius*cos(\x)}, {\radius*sin(\x)});
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\draw [tdplot_rotated_coords,domain=90+\Beta:270+\Beta] plot ({\radius*cos(\x)}, {\radius*sin(\x)});
\tdplotsetrotatedcoords{\Alpha}{\Beta}{0}
\draw [tdplot_rotated_coords,fill=black,fill opacity=0.1,domain=0:90] plot ({\radius*cos(\x)}, {\radius*sin(\x)});

\tdplotsetrotatedcoords{\Alpha}{\Beta}{0}
\draw [tdplot_rotated_coords,domain=-50:0] plot ({\radius*cos(\x)}, {\radius*sin(\x)});


% Arrows for alpha, beta, gamma
\tdplotsetrotatedcoords{0}{0}{0}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{0}{\Alpha}{anchor=east}{$\alpha$}
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{-90}{-90+\Beta}{anchor=east}{$\beta$}
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{-\Gamma}{0}{anchor=east}{$\gamma$}

\tdplotsetrotatedcoords{0}{0}{0}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{90}{90+\Alpha}{anchor=east}{$\alpha$}
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{-180}{-180+\Beta}{anchor=east}{$\beta$}
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\tdplotdrawarc[tdplot_rotated_coords,-latex]{(0,0,0)}{0.8*\radius}{90-\Gamma}{90}{anchor=east}{$\gamma$}

\end{tikzpicture}
\end{document}

答案1

瞧。我不确定我是否真的理解了它的tikz-3dplot工作原理(如果我读了文档,无疑会有帮助),并且(大部分)都是按照原始代码的思路进行的。

我只是改变了绘制顺序,并使用裁剪来绘制位于其他表面后面的虚线。这导致代码相当混乱,因为(例如)轴没有组合在一起(这本来是理想的)。

\Alpha如果、\Beta\Gamma参数发生重大变化,事情无疑会崩溃。

\documentclass[border=0.125cm]{standalone}
\usepackage{tikz} 
\usepackage{tikz-3dplot}

\def\radius{6}
\def\Alpha{20}
\def\Beta{20}
\def\Gamma{20}

\begin{document}


\tdplotsetmaincoords{70}{150}

\tikzset{% Some styles. More could be done.
    axis/.style={very thick, fill=white, -*, shorten >=-3pt},
    axis'/.style={thick, -},
    axis''/.style={thick, -},
    Axis/.style={very thick, fill=black, -*, shorten >=-3pt},
    behind lines/.style={loosely dashed}
}

\begin{tikzpicture}[tdplot_main_coords]

\begin{scope}[scale=\radius, every path/.style={tdplot_rotated_coords}]

% Back half of the white circle.
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw  [fill=white] 
    plot    [domain=90:270, samples=100] (cos \x, sin \x) -- cycle;

% The light gray circle
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\draw  [fill=gray!20] 
    plot    [domain=0:360, samples=100] (cos \x, sin \x);

% The dashed edge of the back half of the white circle
\begin{scope}
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\path  [clip] 
    plot    [domain=0:360, samples=100] (cos \x, sin \x);

\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw  [behind lines] 
    plot    [domain=90:270, samples=100] (cos \x, sin \x);
\end{scope}

% The upper (unfilled) semi circles
\tdplotsetrotatedcoords{\Alpha}{90}{0}
\draw [domain=90:270, samples=100] plot (cos \x, sin \x);
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\draw [domain=90+\Beta:270+\Beta, samples=100] plot (cos \x, sin \x);


% The dark gray sector
\tdplotsetrotatedcoords{\Alpha-90}{-90}{90}
\draw [fill=gray, thick, domain=0:\Beta] 
    (0,0) -- plot (cos \x, sin \x) -- cycle;

% The X axis
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\draw[Axis] (0,0,0) -- (1,0,0) node [below left] {$X$};

% The x'' axis
\tdplotsetrotatedcoords{\Alpha}{\Beta}{0}
\draw[axis'] (0,0,0) -- (1,0,0) node [below left] {$x''$};

% The front half of the white circle
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw  [fill=white] 
    plot [domain=-90:0, samples=100] (cos \x, sin \x) 
    .. controls (0.125*cos 22.5, 0.125*sin 22.5) ..
    (cos 45, sin 45) -- plot    [domain=45:90, samples=100] (cos \x, sin \x) 
    -- cycle;

% The dashed lines in the front half of the white circle
\begin{scope}
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\path  [clip] 
    plot [domain=-90:0, samples=100] (cos \x, sin \x) 
    .. controls (0.125*cos 22.5, 0.125*sin 22.5) ..
    (cos 45, sin 45) -- plot    [domain=45:90, samples=100] (cos \x, sin \x) 
    -- cycle;

\tdplotsetrotatedcoords{\Alpha-90}{-90}{90}
\draw [behind lines] (0,0) -- (cos \Beta, sin \Beta);

\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\draw [behind lines] (0,0,0) -- (1,0,0);

\end{scope}


% Axes x, y, z
\tdplotsetrotatedcoords{0}{0}{0}
\draw[axis] (0,0,0) -- (1,0,0) node [below left]  {$x$};
\draw[axis] (0,0,0) -- (0,1,0) node [below right] {$y$};
\draw[axis] (0,0,0) -- (0,0,1) node [above=0.1cm] {$z=z'$};

% Axis x'
\tdplotsetrotatedcoords{\Alpha}{0}{0}
\draw[axis] (0,0,0) -- (1,0,0) node [below left] {$x'$};

% Axes Y
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\draw[Axis] (0,0,0) -- (0,1,0) node [right] {$Y$};
% Axes z' and Z
\draw[Axis] (0,0,0) -- (0,0,1) node [left=0.1cm] {$z''=Z$};

% Axes y' and y''
\tdplotsetrotatedcoords{\Alpha}{\Beta}{0}
\draw[axis'] (0,0,0) -- (0,1,0) node [below right] {$y'=y''$};

% Arrows
\tdplotsetrotatedcoords{0}{0}{0}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{0}{\Alpha}{below left=0cm}{$\alpha$}
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{-90}{-90+\Beta}{left}{$\beta$}
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{-\Gamma}{0}{below}{$\gamma$}

\tdplotsetrotatedcoords{0}{0}{0}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{90}{90+\Alpha}{above left=0cm}{$\alpha$}
\tdplotsetrotatedcoords{\Alpha+90}{90}{0}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{-180}{-180+\Beta}{above}{$\beta$}
\tdplotsetrotatedcoords{\Alpha}{\Beta}{\Gamma}
\tdplotdrawarc[-latex]{(0,0,0)}{0.8}{90-\Gamma}{90}{left}{$\gamma$}

\end{scope}

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容