7

Consider the following code:

\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}

What I want to do is, to draw an arc where two endpoints are R and X, and the center of the arc is O. How can I do this by not manually calculating the angle of the two lines OR and OX?

enter image description here

9

You can use the angles-library of tikz.

Add angles to your \usetikzlibrary

\usetikzlibrary{intersections, calc, angles}

Add at the end of your code:

\coordinate (o) at (3,4);
\pic [draw, angle radius=3.5cm] {angle=a--o--b};

The points R and X are already defined by the two intersection points a and b. You just need to add a coordinate at your point O to let tikz do the work.

EDIT: Complete example with explicit coordinates

\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}

rendered image

6

One option: let draw the circle again, but clip it whitin the area defined by O-R-P-Q-O.

Note: I've changed some pairs (x,y) node {...} by labelled coordinates: (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}

enter image description here

Update:

Your code defines a large bounding box because you use a complete circle around O. If you need to obtain a more adjusted graphic, you can use only the arc corresponding to the third quadrant of the circle:

\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}

enter image description here

5

You could use tkz-euclide package.

In this way you have only to add

\tkzDrawArc(origin,a)(b) 

and define

`\node at (3,4) (origin) {};` 

(you can also use \coordinate for the point definition, of course).

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.