Ticker

6/recent/ticker-posts

How to draw Trigonometric Circle using TikZ LaTeX

Code in TikZ \(\LaTeX\)

A complete guide to draw trigonometric circle in \(\LaTeX\).
First of all, select documentclass which is stanalone in our case and set margins to 5mm on all sides and use the package tikz to draw. Begin the document and the tikzpicture environment with scaling, arrowhead and arrow style options
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=5.3,cap=round,>=latex]

Draw \(x\) and \(y\) axis with node arrowhead direction to right with fill option as white
\draw[->] (-1.5cm,0cm) -- (1.5cm,0cm) node[right,fill=white] {$x$}; % x axis
\draw[->] (0cm,-1.5cm) -- (0cm,1.5cm) node[above,fill=white] {$y$}; % y axis


Draw unit circle centered at \((0,0)\)
\draw[thick] (0cm,0cm) circle(1cm);

The loop in Tikz is generated by using foreach command. In this loop gray color lines were drawn from center to point of multiples of 30 degrees and their bissections i.e., 45, 135, 225, 315. Also dots were created at each point on the intersection of lines and circle.
\foreach \x in {45,135, 225,315,0,30,...,360} {
\draw[gray] (0cm,0cm) -- (\x:1cm);
\filldraw[black] (\x:1cm) circle(0.4pt);
}

For the first and fourth quadrants, for loop is created to display values on the circle at the associated angles.
\adeg stands for angle in degree, \radtext stands for angle in radian, \xc and \yc are the coordinates values of the angle.
In the loop, firstly values are defined and the using draw command, then angles in degree and radians with minor shifts are displayed on the line generated above. And finally coordinates were placed at west direction of the point. rotate around, anchor keys were used for such placements
\foreach \adeg/\radtext/\xc/\yc in {
30/\frac{\pi}{6}/\frac{\sqrt{3}}{2}/\frac{1}{2},
45/\frac{\pi}{4}/\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
60/\frac{\pi}{3}/\frac{1}{2}/\frac{\sqrt{3}}{2},
300/\frac{5\pi}{3}/\frac{1}{2}/-\frac{\sqrt{3}}{2},
315/\frac{7\pi}{4}/\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
330/\frac{11\pi}{6}/\frac{\sqrt{3}}{2}/-\frac{1}{2}
}
{
\draw (\adeg:0.6cm) node[fill=white, rotate around={\adeg:(0,0)}] {$\adeg^\circ$};
\draw (\adeg:0.85cm) node[fill=white, rotate around={\adeg:(0,0)}] {$\radtext$};
\draw (\adeg:1.025cm) node[fill=white, rotate around={\adeg:(0,0)}, anchor=west] {$\left(\xc,\yc\right)$};
}

Similarly, all the operations perfomed above were repeated for the second and third quadrants with slighter change of dirction from west to east
\foreach \adeg/\radtext/\xc/\yc in {
120 / \frac{2\pi}{3} / -\frac{1}{2} / \frac{\sqrt{3}}{2},
135 / \frac{3\pi}{4} / -\frac{\sqrt{2}}{2} / \frac{\sqrt{2}}{2},
150 / \frac{5\pi}{6} / -\frac{\sqrt{3}}{2} / \frac{1}{2},
210 / \frac{7\pi}{6} / -\frac{\sqrt{3}}{2} / -\frac{1}{2},
225 / \frac{5\pi}{4} / -\frac{\sqrt{2}}{2} / -\frac{\sqrt{2}}{2},
240 / \frac{4\pi}{3} / -\frac{1}{2} / -\frac{\sqrt{3}}{2}
}
{
\draw (\adeg:0.6cm) node[fill=white, rotate around={\adeg+180:(0,0)}] {$\adeg^\circ$};
\draw (\adeg:0.85cm) node[fill=white, rotate around={\adeg+180:(0,0)}] {$\radtext$};
\draw (\adeg:1.025cm) node[fill=white, rotate around={\adeg+180:(0,0)}, anchor=east] {$\left(\xc,\yc\right)$};
}

Now, do the above operions for the angles at \(x\) axis
\foreach \adeg/\radtext/\xc/\yc in {0 / 2\pi / 1 / 0, 180 / \pi / -1 / 0}
{
\draw (\adeg:0.6cm) node[fill=white, above=1pt] {$\adeg^\circ$};
\draw (\adeg:0.85cm) node[fill=white, above=1pt] {$\radtext$};
\draw (\adeg:1.15cm) node[fill=white, above=1pt] {$\left(\xc,\yc\right)$};
}

And for the angles at \(y\) axis
\foreach \adeg/\radtext/\xc/\yc in {90 / \frac{\pi}{2} / 0 / 1, 270 / \frac{3\pi}{2} / 0 / -1}
{
\draw (\adeg:0.6cm) node[fill=white, right=1pt] {$\adeg^\circ$};
\draw (\adeg:0.85cm) node[fill=white, right=1pt] {$\radtext$};
\draw (\adeg:1.1cm) node[fill=white, right=1pt] {$\left(\xc,\yc\right)$};
}

Closing tikzpicture environment and document
\end{tikzpicture}
\end{document}

Final Output

Post a Comment

0 Comments