[Tex/LaTex] Tikz draw an accurate angle in a circle

tikz-pgf

enter image description here

Here is an illustration in which the angles are not accurately drawn.

I want to know whether there is an easier way to draw an accurate angle within a circle, say $\angle ABD = 15^\circ$.

Here is what I have done, from the very beginning:

\begin{tikzpicture}[scale=2]
    \coordinate (O) at (0,0);
    \draw (O) circle (1);
    \coordinate [label=above left:$A$] (A) at (105:1);
    \coordinate [label=below left:$B$] (B) at (225:1);
    \draw (A) -- (B);
\end{tikzpicture}

The next steps are draw angles of 15 and 30 degrees from the segment AB, to determine C and D (on the circle).

I wonder if this can be done easily using any TikZ packages?

Best Answer

For compass and protractor constructions, one can actually just use the through library, the calc library and the intersection cs. The turn key can help to find relative polar coordinates.

The through library only provides one key which has to be used with a node: circle through.

It creates a node of the shape circle that has its center at the at part of the node and goes through the point given to the key. I am using the point (right:1) which is the compass-direction version of (0:1) (which is the polar version of (1, 0)).

This allows me to create a circle with dimensions that scales with the scale value without using transform shape or calculating stuff beforehand (which basically is handled by the through library). For different x scale and y scale or other transformations (setting the x and/or y vector for example) will most likely fail anyway, and you will need to use a circle/ellipse path operator. However, the intersection cs can only work with circle nodes and lines (or two lines or two circular nodes). It really is something for compass and protractors.

If the circle’s center (as in our example) does not lie on the origin, you will need to use circle through={([shift={(<center>)}]0:<radius>)}.


The naming of the node ci is needed for

  • the use with intersection cs as it needs the name of a (circular) node and
  • the use of its anchor-border where one can use arbitrary angles.

If you don’t use a circular node, instead of (ci.<angle>), you would use (<angle>:<radius>) or ([shift={(<center>)}]<angle>:<radius>).


The points can then be found with:

\usetikzlibrary{through, calc} % preamble

\begin{tikzpicture}[scale=2]
    \coordinate (O) at (0,0);
    \node[draw] (ci) at (O) [circle through=(right:1)] {};
    \coordinate [label=above left:$A$] (A) at (ci.105);
    \coordinate [label=below left:$B$] (B) at (ci.225);
    \path (A) -- (B) -- ([turn]-15:-1) coordinate (B')
          (B) -- (A) -- ([turn]30:-1) coordinate (A');
    \path (intersection cs: first node=ci, second line={(B)--(B')})
      coordinate[label=above:$C$] (C)
          (intersection cs: first node=ci, second line={(A)--(A')})
      coordinate[label=below right:$D$] (D);
    \draw (A) -- (B) -- (C) -- (D) -- cycle [line join=bevel];
\end{tikzpicture}

Unfortunately, this is not very accurate when it comes to circles:

enter image description here enter image description here


The intersections library can find intersections between arbitrary paths, not only circles and straight lines. However, a little more work is needed, as path need to be named and the used paths actually need to intersect.

\usetikzlibrary{through, intersections} % preamble

\begin{tikzpicture}[scale=2]
    \coordinate (O) at (0,0);
    \node[draw, name path=ci] (ci) at (O) [circle through=(right:1)] {};
    % or \draw [name path=ci] (O) circle[radius=1];
    \coordinate [label=above left:$A$] (A) at (ci.105);
    \coordinate [label=below left:$B$] (B) at (ci.225);
    \path[overlay] (A) -- (B) -- ([turn]-15:-3) coordinate (B');
    \path[overlay] (B) -- (A) -- ([turn]30:-3) coordinate (A');
    \path[overlay, name path=A] (A) -- (A');
    \path[overlay, name path=B] (B) -- (B');
    \path[name intersections=
      {of=A and ci, by={@,[label=below right:$D$]D}}]; % @ is not used (equals A)
    \path[name intersections={of=B and ci, by={[label=above:$C$]C}}];
    \draw (A) -- (B) -- (C) -- (D) -- cycle [line join=bevel];
\end{tikzpicture}

The solution is more correct:

enter image description here


You can also do the calculations beforehand

enter image description here

and just use TikZ for drawing:

\begin{tikzpicture}[scale=2]
    \coordinate (O) at (0,0);
    \node[draw] (ci) at (O) [circle through=(right:1)] {};
    \coordinate [label=above left:$A$]  (A) at (ci.105);
    \coordinate [label=below left:$B$]  (B) at (ci.225);
    \coordinate [label=      above:$C$] (C) at (ci.225-150);
    \coordinate [label=below right:$D$] (D) at (ci.105-180);
    \draw (A) -- (B) -- (C) -- (D) -- cycle [line join=bevel];
\end{tikzpicture}

enter image description here