考虑以下代码:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[auto]
\draw (0,0) node[below] {$P$} -- (2,0) node[below] {$Q$};
\path[name path=circ] (3,4) node[above] {$O$} circle (3.5);
\path[name path=l1] (0,0) -- (0, 4);
\path[name path=l2] (2,0) -- (2,4);
\path[name intersections={of=l1 and circ, by=a}];
\path[name intersections={of=l2 and circ, by=b}];
\draw (0,0) -- (a) node[above] {$R$};
\draw (2,0) -- (b) node[above] {$X$};
\draw[densely dotted] (3,4) -- (3,0) node[right] {$Z$} -- (2,0);
\draw[densely dotted] (b) -- (b -| 3,0) node[right] {$Y$} (a) -- (a -| 3,0) node[right] {$S$};
\draw[densely dotted] (a) -- (3,4) -- (b);
\draw[|<->|] (-0.1, 0) -- node {$H$} ($ (a) +(-.1,0) $);
\draw[|<->|] (2.1,0) -- node[swap] {$h$} ($ (b) +(.1,0) $);
\draw[|<->|] (0, .1) --node {$d$} (2,.1);
\end{tikzpicture}
\end{document}
我想要做的是绘制一个圆弧,两个端点是 R 和 X,圆弧的中心是 O。我怎样才能做到这一点,而不手动计算两条线 OR 和 OX 的角度?
答案1
您可以使用angles
tikz 的库。
添加angles
到您的\usetikzlibrary
\usetikzlibrary{intersections, calc, angles}
在代码末尾添加:
\coordinate (o) at (3,4);
\pic [draw, angle radius=3.5cm] {angle=a--o--b};
要点R和X已经由两个交点a
和定义b
。您只需添加一个coordinate
在点处添加一个哦让 tikz 完成工作。
编辑:具有明确坐标的完整示例
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{intersections, calc, angles}
\begin{document}
\begin{tikzpicture}
\coordinate [label=below:$P$] (p) at (0,0);
\coordinate [label=below:$Q$] (q) at (2,0);
\coordinate [label=above:$O$] (o) at (3,4);
\path [name path=l1] (p) -- +(0,4);
\path [name path=l2] (q) -- +(0,4);
\path [name path=circ] ($(o)+(200:3.5cm)$) arc (200:260:3.5cm);
\path [name intersections={of=l1 and circ, by=ri}];
\path [name intersections={of=l2 and circ, by=xi}];
\coordinate [label=above:$R$] (r) at (ri);
\coordinate [label=above:$X$] (x) at (xi);
\coordinate [label=right:$S$] (s) at (r-|o);
\coordinate [label=right:$Y$] (y) at (x-|o);
\coordinate [label=below:$Z$] (z) at (q-|o);
\draw (r) -- (p) -- (q) -- (x);
\begin{scope}[dotted]
\draw (r) -- (s) (q) -- (z) -- (o) (x) -- (y) (r) -- (o) -- (x);
\pic [draw, angle radius=3.5cm] {angle=r--o--x};
\end{scope}
\begin{scope}[|<->|]
\draw ([xshift=-.1cm]r) -- ([xshift=-.1cm]p) node [midway, left] {$H$};
\draw ([xshift=.1cm]q) -- ([xshift=.1cm]x) node [midway, right] {$h$};
\draw ([yshift=.1cm]p) -- ([yshift=.1cm]q) node [midway, above] {$d$};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
一个选择:再次绘制圆圈,但将其剪裁在 ORPQO 定义的区域内。
(x,y) node {...}
注意:我通过标记坐标更改了一些对:(x,y) coordinate[label=below:...] (...)
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[auto]
\draw (0,0) coordinate[label=below:$P$] (P) -- (2,0) coordinate[label=below:$Q$] (Q);
\path[name path=circ] (3,4) coordinate[label=$O$] (O) circle (3.5);
\path[name path=l1] (0,0) -- (0,4);
\path[name path=l2] (2,0) -- (2,4);
\path[name intersections={of=l1 and circ, by=R}];
\path[name intersections={of=l2 and circ, by=X}];
\draw (0,0) -- (R) node[above] {$R$};
\draw (2,0) -- (X) node[above] {$X$};
%The arc is drawn here
\begin{scope}
\clip (O)--(R)--(P)--(X)--cycle;
\draw[red, densely dotted] (O) circle (3.5);
\end{scope}
\draw[densely dotted] (3,4) -- (3,0) node[right] {$Z$} -- (2,0);
\draw[densely dotted] (X) -- (X -| 3,0) node[right] {$Y$} (R) -- (R -| 3,0) node[right] {$S$};
\draw[densely dotted] (R) -- (3,4) -- (X);
\draw[|<->|] (-0.1, 0) -- node {$H$} ($ (R) +(-.1,0) $);
\draw[|<->|] (2.1,0) -- node[swap] {$h$} ($ (X) +(.1,0) $);
\draw[|<->|] (0, .1) --node {$d$} (2,.1);
\end{tikzpicture}
\end{document}
更新:
您的代码定义了一个较大的边界框,因为您在周围使用了一个完整的圆O
。如果您需要获得更加调整的图形,则可以仅使用与圆的第三象限相对应的圆弧:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[auto]
\draw (0,0) coordinate[label=below:$P$] (P) -- (2,0) coordinate[label=below:$Q$] (Q);
\coordinate[label=$O$] (O) at (3,4);
\path[name path=circ] (-0.5,4) arc[start angle=180, end angle=270, radius=3.5];
% \path[name path=circ] (3,4) coordinate[label=$O$] (O) circle (3.5);
\path[name path=l1] (P) -- (0,4);
\path[name path=l2] (Q) -- (2,4);
\path[name intersections={of=l1 and circ, by=R}];
\path[name intersections={of=l2 and circ, by=X}];
\draw (0,0) -- (R) node[above] {$R$};
\draw (2,0) -- (X) node[above] {$X$};
\begin{scope}
\clip (O)--(R)--(P)--(X)--cycle;
\draw[red, densely dotted] (O) circle (3.5);
\end{scope}
\draw[densely dotted] (O) -- (3,0) node[right] {$Z$} -- (Q);
\draw[densely dotted] (X) -- (X -| O) node[right] {$Y$} (R) -- (R -| O) node[right] {$S$};
\draw[densely dotted] (R) -- (O) -- (X);
\draw[|<->|] (-0.1, 0) -- node {$H$} ($ (R) +(-.1,0) $);
\draw[|<->|] (2.1,0) -- node[swap] {$h$} ($ (X) +(.1,0) $);
\draw[|<->|] (0, .1) --node {$d$} (2,.1);
\end{tikzpicture}
\end{document}
答案3
您可以使用tkz-euclide
包。
这样你只需要添加
\tkzDrawArc(origin,a)(b)
并定义
`\node at (3,4) (origin) {};`
\coordinate
(当然,您也可以使用它来定义点)。
\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[auto]
\draw (0,0) node[below] {$P$} -- (2,0) node[below] {$Q$};
\node at (3,4) (origin) {};
\path[name path=circ] (3,4) node[above] {$O$} circle (3.5);
\path[name path=l1] (0,0) -- (0, 4);
\path[name path=l2] (2,0) -- (2,4);
\path[name intersections={of=l1 and circ, by=a}];
\path[name intersections={of=l2 and circ, by=b}];
\draw (0,0) -- (a) node[above] {$R$};
\draw (2,0) -- (b) node[above] {$X$};
\draw[densely dotted] (3,4) -- (3,0) node[right] {$Z$} -- (2,0);
\draw[densely dotted] (b) -- (b -| 3,0) node[right] {$Y$} (a) -- (a -| 3,0) node[right] {$S$};
\draw[densely dotted] (a) -- (3,4) -- (b);
\draw[|<->|] (-0.1, 0) -- node {$H$} ($ (a) +(-.1,0) $);
\draw[|<->|] (2.1,0) -- node[swap] {$h$} ($ (b) +(.1,0) $);
\draw[|<->|] (0, .1) --node {$d$} (2,.1);
\tkzDrawArc(origin,a)(b)
\end{tikzpicture}
\end{document}