Tikz - 更改对象边框线类型 - 组合实线和虚线

Tikz - 更改对象边框线类型 - 组合实线和虚线

我想帮助改进下一幅费曼图。有几个人帮我在不规则形状的物体中定位椭圆(问题74335)。

TikZ 代码是:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}

\begin{document}
    \begin{figure}[hb!]
        \centering
            \begin{tikzpicture}
              \coordinate (dS) at (1.5,0.5);
              \shade [name path=teleso,ball color=gray!10!brown,opacity=0.50,line width=1,draw=black] 
                    plot [smooth cycle] coordinates 
                    { (0,0) (1,-1) (3,0) (2.5,2) (3,3) (3,4) (2,5) (-1,3) };
              \draw (3,4) node[right]{$S_a$};      
              \draw (0,0) node[below]{$S_b$};
              % ploska dS      
              \shade[bottom color=gray!10!brown,opacity=0.50, shading angle=60](dS) 
                    node[below, text=black]{$dS$} rectangle +(0.5,0.5);
              \draw [->] (dS) ++ (0.25,0.25) -- +(30:0.5) node[right]{$\vec{n}$};
              \draw [->] (dS) ++ (0.25,0.25) -- +(60:0.7) node[right]{$\vec{C}$};
              % text
              \draw [fill=black] (2,4) circle (0.05) node[above, black]{$V_1$};
              \draw [fill=black] (1,0.5) circle (0.05) node[above, black]{$V_2$};
              % line - division of object             
              \path [name path=line1](-1.5,3) -- (3,2);
              % Intersections
              \path [name intersections={of=teleso and line1, name=cross}];
              % ellipse 
              \coordinate (A) at (cross-1);
              \coordinate (B) at (cross-2);
              \fill [color=cyan, opacity=0.25] let \p1=(A),\p2=(B),
                    \n1={atan2(\y2-\y1,\x2-\x1)},\n2={veclen(\y2-\y1,\x2-\x1)} in
                    [rotate=90-\n1] ($ (A)!0.5!(B) $) ellipse (\n2/2 and 0.7cm);
              % vectors 
              \draw [->] let \p1=(A),\p2=(B),
                    \n1= {atan2(\y2-\y1,\x2-\x1)} in
                    ($ (A)!0.5!(B) $) -- +(360-\n1:1)  node[right]{$\vec{n}_1$};  % relative 
              \draw [->, dashed] let \p1=(A),\p2=(B),
                    \n1= {atan2(\y2-\y1,\x2-\x1)} in 
                    ($ (A)!0.5!(B) $) -- +(180-\n1:1) node[right]{$\vec{n}_2$};   % relative                
            \end{tikzpicture} 
    \end{figure}
\end{document}

问题

  1. 按照命令\shade[bottom color=gray!10!brown,opacity=0.50, shading angle=60](dS) node[below, text=black]{$dS$} rectangle +(0.5,0.5);节点已经用 定义了文本颜色text = black,但可以看到,图中的文本“dS”并不是黑色。
  2. 此外,我想用椭圆的边界线来表示物体的三维特征。一部分必须用实线绘制,第二部分(后部)应为虚线。椭圆是通过命令绘制的\fill
  3. 如何更好地指定文本位置(文本“Sa”太粘在物体上了)

输出

费曼

答案1

对于文本,dS我建议使用额外节点的解决方法:

\shade[
    bottom color=gray!10!brown,
    opacity=0.50,
    shading angle=60
] (dS) rectangle +(0.5,0.5);
\node [below] at (dS) {$dS$};

您可能希望使其更加用户友好(单一宏,无需重复计算)...

\draw[very thick,cyan] let \p1=(A),
          \p2=(B),
              \n1={atan2(\y2-\y1,\x2-\x1)},
              \n2={veclen(\y2-\y1,\x2-\x1)}
            in [rotate=90-\n1] ($ (A)!0.5!(B)+(0:\n2/2)$) arc[start angle=0,
                                                              delta angle=180,
                                                                 x radius=\n2/2,
                                                                 y radius=0.7cm];

\draw[very thick,dashed,cyan] let \p1=(A),
              \p2=(B),
              \n1={atan2(\y2-\y1,\x2-\x1)},
              \n2={veclen(\y2-\y1,\x2-\x1)}
            in [rotate=90-\n1] ($ (A)!0.5!(B)+(180:\n2/2)$) arc[start angle=180,
                                                                delta angle=180,
                                                                   x radius=\n2/2,
                                                                   y radius=0.7cm];

给出 椭圆


right可以通过、below、等键的值对定位进行微调left

\draw (3,4) node[right=1mm] {$S_a$};
\draw (0,0) node [left=1mm] {$S_b$};

相关内容