半球 Tikz

半球 Tikz

我正在尝试绘制一个使用 Tikz 识别对映点的球体

在此处输入图片描述

谁能帮我?

谢谢 :)

答案1

这是伪 3D 尝试元帖子。如您所见,执行透明度等操作有点麻烦。对于任何更复杂的事情,Asymptote 在 3D 方面表现更好。

在此处输入图片描述

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

    color husky; 
    husky = 1/256(208, 170, 109);

    path c, e, a[];
    c = fullcircle scaled 144;
    e = c yscaled 1/4;
    a1 = reverse c rotated 90 xscaled 1/3 cutbefore subpath (0,4) of e cutafter subpath (4,8) of e; 
    a2 = reverse c rotated 90 xscaled 2/3 cutbefore subpath (0,4) of e cutafter subpath (4,8) of e; 

    fill subpath(4,8) of c -- cycle withcolor husky;
    draw subpath(4,8) of c -- cycle;
    fill e withcolor 1/3[husky,white];
    draw subpath (2,6) of e withcolor .5 white;
    draw subpath (-2,2) of e withcolor .5 red;

    ahangle := 30;

    forsuffixes @=1,2:
        draw a@ withcolor .8[black+1/3red,husky];
        draw a@ cutafter subpath(6, 7) of e;;
        drawarrow subpath(3,4.4) of a@;
        draw subpath(4.4,5) of a@;
        drawarrow point infinity of a@ -- point 0 of a@
            cutbefore fullcircle scaled 5 shifted point infinity of a@
            cutafter  fullcircle scaled 10 shifted point 0 of a@;
        label.lrt(char (96+@) infont "cmmi7", point 0 of a@);
        label.llft(char (96+@) infont "cmmi7", point infinity of a@);
    endfor

endfig;
end.

答案2

这是使用 TikZ 的答案。如果我能自动计算弧线从后向前相交的角度就更好了,但我懒得去算数学题。

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, decorations.markings}
\begin{document}
\pgfkeys{/tikz/.cd, view angle/.initial=0, view angle/.store in=\picangle}
\tikzset{
  horizontal/.style={y={(0,sin(\picangle))}},
  vertical at/.style={x={([horizontal] #1:1)}, y={(0,cos(\picangle)cm)}},
  every label/.style={font=\tiny, inner sep=1pt},
  shorten/.style={shorten <=#1, shorten >=#1},
  shorten/.default=3pt,
  ->-/.style={decoration={markings, mark=at position #1 with {\arrow{>}}}, postaction={decorate}},
  ->-/.default=0.5
}
\begin{tikzpicture}[scale=2, view angle=15, >=stealth]
  % Back of sphere
  \draw[fill=brown!50, fill opacity=.75, horizontal] (0,0) circle (1);
  \draw[vertical at=55] (0:1) coordinate[label=below right:$a$] (a1) arc (0:-110:1);
  \draw[vertical at=75] (0:1) coordinate[label=below right:$b$] (b1) arc (0:-105:1);
  % Front of sphere
  \draw[fill=brown, fill opacity=.75] (0:1) arc (0:-180:1) [horizontal] arc (-180:0:1);
  \draw[vertical at=55, ->-] (-110:1) arc (-110:-180:1) coordinate[label=below left:$a$] (a2);
  \draw[vertical at=75, ->-] (-105:1) arc (-105:-180:1) coordinate[label=below left:$b$] (b2);
  % Other stuff
  \draw[->, shorten] (a2) -- (a1);
  \draw[->, shorten] (b2) -- (b1);
  \draw[horizontal, red] (90:1) arc (90:-90:1);
  \draw[horizontal, blue] (90:1) arc (90:270:1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容