思路如下:先找到两圆的交点,再分别画右边小圆的两段弧,左边一段弧画成虚线,右边一段弧正常即可。
注:1.使用let ... in ...
操作是为了找到两段弧的开始角度与结束角度。
2.使用atan
反正切函数,注意此函数求出的角的范围是(-90,90)度。
3.使用库:intersections
求交点坐标,calc
实现坐标计算功能。
\documentclass[border=8pt,tikz]{standalone}
\usepackage{amssymb}
\usetikzlibrary{patterns,intersections,calc}
\begin{document}
\begin{tikzpicture}
\path [draw, very thick, ->] node at (-.3,-.3) {$O$} (-0.5,0) -- (8,0) node[anchor=north] {$x$};
\path [draw,very thick, ->](0,-0.5) -- (0,6.1) node[anchor=east] {$y$};
\node at (7.5,5.5) {$\mathbb{R}^{2}$};
\draw[very thick,blue,dashed,-] (0.5,0.5) -- (6.5,0.5) -- (6.5,5) --(0.5,5)--(0.5,0.5);
\draw[pattern=north west lines,name path=circle1,draw=red] (3,3) circle (1.5);
\node [fill=white,rounded corners,below of=3] at (2.5,4) {$B$};
\node at (2,1.3) {$ {\color{red}\partial B=B_{0}}$};
\path[name path=circle2] (5,3) circle (1.2);
%左边一段弧,dashed
\draw[dashed,name intersections={of=circle1 and circle2,name=i}]
let \p1=($(5,3)-(i-1)$), \p2=($(5,3)-(i-2)$), \n1={atan(\y1/\x1)}, \n2={atan(\y2/\x2)}
in (i-1) arc({\n1+180}:{\n2+180}:1.2);
%右边一段弧
\draw let \p1=($(5,3)-(i-1)$), \p2=($(5,3)-(i-2)$), \n1={atan(\y1/\x1)}, \n2={atan(\y2/\x2)}
in (i-1) arc({\n1+180}:{\n2-180}:1.2);
\node at (6.2,1) {$\Lambda$};
\node at (5.5,3) {$S$};
\end{tikzpicture}
问 绘图如何实现立体效果?