对于一道几何题,我画了一张图,代码如下:
\begin{figure}[htb!]
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\draw [line width=1.4pt] (0,0) arc (180:0:4);
\draw [line width=1.4pt] (4,0) arc (180:0:4);
\draw [line width=1.4pt] (0,0) -- (12,0);
\draw [line width=1.4pt] (6,1.5) circle (1.5cm);
\draw [line width=1.4pt, color=red] (4,0) -- (6,3.4641016151377544);
\draw [line width=1.4pt, color=red] (8,0) -- (6,3.4641016151377544);
\begin{scriptsize}
\draw [fill=black] (0,0) circle (2pt);
\draw[color=black] (-0.23,-0.23) node {$A$};
\draw [fill=black] (8,0) circle (2pt);
\draw[color=black] (8,-0.23) node {$B$};
\draw [fill=black] (4,0) circle (2pt);
\draw[color=black] (4,-0.23) node {$C$};
\draw [fill=black] (12,0) circle (2pt);
\draw[color=black] (12.23,-0.23) node {$D$};
\draw [fill=black] (6,1.5) circle (2pt);
\draw[color=black] (6.2,1.3) node {$O$};
\draw [fill=black] (6,0) circle (2pt);
\draw[color=black] (6,-0.23) node {$T$};
\draw [fill=black] (6,3.4641016151377544) circle (2pt);
\draw[color=black] (6, 3.75) node {$E$};
\draw [fill=black] (4.8,2.4) circle (2pt);
\draw[color=black] (4.65,2.55) node {$P$};
\draw [fill=black] (7.2,2.4) circle (2pt);
\draw[color=black] (7.45,2.55) node {$Q$};
\end{scriptsize}
\end{tikzpicture}
\end{figure}
得出的结果为:
如何为圆弧 EB(包含点 Q 的圆弧)和线段 EB 所围成的区域着色?
答案1
一个可能的解决方案是填充整个圆圈并将其剪切(我使用 BDE 三角形进行剪切)。
我对原始绘图做了一些修改,使用calc
库来获取没有合理坐标的点。
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[thick,line cap=round]
% coordinates
\pgfmathsetmacro\a{atan(0.75)}
\coordinate (A) at (-6,0);
\coordinate (D) at (6,0);
\coordinate (B) at (2,0);
\coordinate (C) at (-2,0);
\coordinate (E) at ($(B)+(120:4)$);
\coordinate (O) at (0,1.5);
\coordinate (P) at ($(O)+(180-\a:1.5)$);
\coordinate (Q) at ($(O)+(\a:1.5)$);
\coordinate (T) at (0,0);
% color fill
\begin{scope}
\clip (B) -- (D) -- (E) -- cycle;
\fill[green] (C) circle (4);
\end{scope}
% original drawing
\draw (B) arc (0:180:4) -- (D) arc (0:180:4);
\draw[red] (B) --++ (120:4) -- (C);
\draw (O) circle (1.5);
% labels
\foreach\i in {A,B,C,D,T}
\fill (\i) circle (1.5pt) node [below] {$\i$};
\fill (E) circle (1.5pt) node [above] {$E$};
\fill (O) circle (1.5pt) node [below right] {$O$};
\fill (P) circle (1.5pt) node [above left] {$P$};
\fill (Q) circle (1.5pt) node [above right] {$Q$};
\end{tikzpicture}
\end{document}
答案2
为了好玩tzplot
:
\documentclass[tikz,border=1mm]{standalone}
\usepackage{tzplot}
\begin{document}
\begin{tikzpicture}[very thick,font=\scriptsize]
% \tzhelplines(-7,-1)(7,5)
%% step by step
% base line
\tzcoors*(-6,0)(A){$A$}[-90](2,0)(B){$B$}[-90](-2,0)(C){$C$}[-90](6,0)(D){$D$}[-90];
\tzline"AD"(A)(D)
% arc
\tzarc"CC"(C)(0:180:4cm)
\tzarc"BB"(B)(0:180:4cm)
% circle
\tzcoors*(0,0)(T){$T$}[b](0,1.5)(O){$O$}[-45];
\tzcircle"circ"(O)(1.5cm)
% intersections
\tzXpoint*{BB}{CC}(E){$E$}
\tzXpoint*{BB}{circ}(P){$P$}[135]
\tzXpoint*{CC}{circ}(Q){$Q$}[45]
% triangle, (arc)fill
\begin{pgfonlayer}{behind}
\tzlines[red,very thick](C)(E)(B);
\end{pgfonlayer}
\begin{pgfonlayer}{background}
\tzarc[draw=none,fill=green](C)(0:60:4cm)
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
答案3
使用 Ti钾Z 库intersections
和pgfplots.fillbetween
图像代码更简洁。点E
、q
和的坐标p
由交点确定,阴影由指令确定\tikzfillbetween
:
\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{intersections,
pgfplots.fillbetween}
\begin{document}
\begin{tikzpicture}[x=1cm, y=1cm,
line cap=round, line join=round,
dot/.style = {circle, fill=black, inner sep=1.5pt},
every label/.style = {font=\scriptsize, text=black, inner sep=1pt},
every path/.style = {draw, very thick}
]
\draw[name path=A] (0,0) arc (180:0:4);
\draw[name path=B] (4,0) arc (180:0:4);
\draw[name intersections={of=A and B, by=e}]
[red, name path=D] (4,0) -- (e) node [dot, label=E] {}
-- (8,0);
% fillbetween
\tikzfillbetween[of=A and D,
split,
every even segment/.style={fill=none}]{blue, opacity=0.25};
%
\draw (0,0) -- (12,0);
\foreach \x/\i in {0/A, 4/C, 6/T, 8/B, 12/12}
\node[dot, label=below:\i] at (\x,0) {};
%
\draw[name path=C] (6,1.5) node[dot, label=below:O] {} circle (1.5cm);
\draw[name intersections={of=A and C, by=q}]
node[dot,label=above right:Q] at (q) {};
\draw[name intersections={of=B and C, by=p}]
node[dot,label=above left:P] at (p) {};
\end{tikzpicture}
\end{document}