[Tex/LaTex] Labeling the lengths and angles in a diagram with measurements

tikz-pgf

I have a diagram that is to be used to define the sine, cosine, and tangent functions. How do I label the drawn radius "r"? How do I draw the angle for alpha? (I am trying to adapt the code that I have. There isn't a manual that explains the syntax.) Two line segments are to be drawn that are perpendicular to the x-axis. One of them is the line segment between the x-axis and the intersection P of the radius and the circle; the other is between the point (r,0) and the ray containing the drawn radius. (The lengths of these line segments are r\sin\alpha and r\tan\alpha.) How do I put a dot at the intersection Q of the second line segment and the ray containing the drawn radius? How do I draw a dotted line segment from P to Q?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%\usetikzlibrary{calc,angles,quotes}
\usepackage{pgfplots}


\begin{document}

\begin{center}
\begin{tikzpicture}[
dot/.style={
  fill,
  circle,
  inner sep=2pt
  }
]
\clip (-0.5,-0.5) rectangle (6,6);
\draw[dashed,fill=white] (0,0) circle [radius=4];
\draw[<->] (-5,0) -- (5,0) node[below] {$x$};
\draw[<->] (0,-5) node (yaxis) {} -- (0,5) node[right] {$y$};
\node[dot,label={right:$(r\cos\alpha, \, r\sin\alpha)$}] at (3.464101615,2) {};
\draw (0,0) -- (3.464101615,2);
\draw[->] (1,0) +(0:1cm) [radius=1cm,start angle=0,end angle=30] node[midway,right]{$\alpha$};


\end{tikzpicture}
\end{center}


\end{document}

Best Answer

This is a possible solution. The point c are on the ray of radius found by the intersections skill from intersections library. Based on \tan \alpha expression, the 2nd line segment has length 1 on the x-axis which is inside the circle of radius 4.

Update Further automation is attempted where a macro \ang can be set between 0 and 90 degree, the intersections library will find the intersection points autmatically. The demonstration is for \ang=45.

  1. How do I label the drawn radius "r"? use node[pos=xx, above=1pt] in the radius
  2. Two line segments are to be drawn that are perpendicular to the x-axis. Use intersections of two curve/lines to find the intersection points b anc c.
  3. How do I put a dot at the intersection of the second line segment and the ray containing the drawn radius? Use of \node[dot](<internal label>){};

enter image description here

Code

\documentclass[border=10pt]{standalone}%
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\def\ang{45}  % 0< \ang<90

\begin{document}

%\begin{center}
\begin{tikzpicture}[
dot/.style={
  fill,
  circle,
  inner sep=2pt
  }
]
\clip (-1,-1) rectangle (5.5,5.5);
\draw[dashed,fill=white,name path=curve] (0,0) coordinate(O){} circle [radius=4];
\draw[<->] (-5,0) -- (5,0) node[below] {$x$};
\draw[<->] (0,-5) node (yaxis) {} -- (0,5) node[right] {$y$};

\path[name path=lineb] (0,0) -- (\ang:5);
\draw[name intersections={of=curve and lineb, by={b}},thick]{};
\node[dot,label={left:$(r\cos\alpha, \, r\sin\alpha)$}] at (b) {};
\draw[->] (0,0) --node[pos=0.7,above]{$\alpha$} (0.8,0) arc (0:\ang:0.8cm) ;
\draw (O) --node[pos=0.7,above=1pt]{$r$} (b) -- (b |- O);

\path[name path=linec] (1,0) -- (1,3);  
\draw[name intersections={of=lineb and linec, by={c}},thick]{};
\draw[] (c) --node[midway,right](){$\tan \alpha$} (c |- O);
\node[dot] at (c){};
\end{tikzpicture}
%\end{center}


\end{document}

enter image description here

Code

\documentclass[border=10pt]{standalone}%{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}
\usepackage{pgfplots}


\begin{document}

%\begin{center}
\begin{tikzpicture}[
dot/.style={
  fill,
  circle,
  inner sep=2pt
  }
]
\clip (-0.5,-0.5) rectangle (7,7);
\draw[dashed,fill=white] (0,0) node(O){} circle [radius=4];
\draw[<->] (-5,0) -- (5,0) node[below] {$x$};
\draw[<->] (0,-5) node (yaxis) {} -- (0,5) node[right] {$y$};
\node[dot,label={left:$(r\cos\alpha, \, r\sin\alpha)$}] at (3.464101615,2) (a) {};
\draw (0,0) -- (3.464101615,2);
\draw[->] (0,0) --node[pos=0.7,above]{$\alpha$} (0.8,0) arc (0:30:0.8cm) ;
\draw (a) -- (a |- O);

% tan alpha

\draw[dashed,name path=linea] (O) -- (a);
\path[name path=linec] (1,0) -- (1,4);
\path[name intersections={of=linea and linec, by={c}},thick]{};
\draw[] (c) --node[midway,right](){$\tan \alpha$} (c |- O);
\node[dot] at (c){};
\end{tikzpicture}
%\end{center}


\end{document}
Related Question