问题如图,本想将右边圆圈的部分弧线画成虚线,奈何不会。。。。。。
%% xelatex FIGhuanrao.tex
\documentclass[border=0pt,tikz]{standalone}
\usepackage{color}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\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] (3,3) circle (1.5);
\draw [color=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}}$};
\draw (5,3) circle (1.2);
\node at (6.2,1) {$\Lambda$};
\node at (5.5,3) {$S$};
\end{tikzpicture}
\end{document}
仍然不太优雅(本可以避免一些dummy的语句的)... 就当抛砖引玉了... 一定有更符合tikz-style更优雅的办法:
基本思路:
\documentclass[border=8pt,tikz]{standalone}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\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);
\node at (6.2,1) {$\Lambda$};
\node at (5.5,3) {$S$};
\draw (5,3) circle (1.2);
\draw[fill=white] (3,3) circle (1.5);
\draw[dashed] (5,3) circle (1.2);
\draw[pattern=north west lines,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}}$};
\end{tikzpicture}
\end{document}
思路如下:先找到两圆的交点,再分别画右边小圆的两段弧,左边一段弧画成虚线,右边一段弧正常即可。
注:1.使用let ... in ...
操作是为了找到两段弧的开始角度与结束角度。
2.使用atan
反正切函数,注意此函数求出的角的范围是(-90,90)度。
3.使用库:intersections
求交点坐标,calc
实现坐标计算功能。
\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}
认为有回答符合需求,请点个采纳,谢谢!
第一步,问AI
,让它计算出角度。
第二步,引用解析式结果,画图:
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{calc,patterns}
\usepackage{amssymb}
\begin{document}
\newcommand{\MyAngle}{{acos(319/480)-180}}% about 48.4-180=-131.6
\newcommand{\MyAngleNeg}{{180-acos(319/480)}}
\begin{tikzpicture}
\draw [->,very thick] (-.5,0) -- (8,0) node [below] {$x$};% x轴
\draw [->,very thick] (0,-.5) -- (0,6) node [left] {$y$};% y轴
\draw [blue,very thick,dashed] (.5,.5) rectangle (6.5,5);% 蓝框
\draw [draw=red,pattern=north west lines] (3,3) circle (1.5);% 左圆
\draw [dashed] ($(5,3)+(\MyAngleNeg:1.2)$) arc (-\MyAngle:\MyAngle :1.2);% 虚线弧
\draw ($(5,3)+( \MyAngle:1.2)$) arc ( \MyAngle:\MyAngleNeg:1.2);% 实线弧
\node at (0,0) [below left] {$O$};
\node at (3,3) [left=9pt,fill=white,rounded corners] {$B$};
\node at (5,3) [right=9pt] {$S$};
\node at (6.5,.5) [above left=3pt] {$\Lambda$};
\node at (.5,.5) [above right=15pt,text=red] {$\partial B=B_0$};
\node at (6.5,5) [above right=9pt] {$\mathbb{R}^2$};
\end{tikzpicture}
\end{document}
\documentclass[border=8pt,tikz]{standalone}
第一行漏掉了,不好意思
@u117881 😀您可以通过“补充回答”,并且可以“删除评论”,让你的代码在本网页的展现效果更好。