5

I have a display of two triangles, but the triangle drawn in red is unintentional. TikZ is misinterpreting the coordinates for point C. The polar coordinates for C is given as \coordinate (C) at (120:5);. TikZ is plotting the point in Quadrant III.

Also, TikZ is misinterpreting the positions at which I want the label for the vertex A and the labels for the angles to be typeset. The command to place A is

\node at ({2.5mm*sqrt(2)/2},{-2.5mm*sqrt(2)/2}){$A$};

and the commands to place $\theta$ are

\coordinate (label_for_theta) at (60:4mm);

\node[font=\footnotesize] at (label_for_theta){$\theta$};.

It seems to me that TikZ is placing these labels using the canvas coordinate system.

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}

\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}


\begin{tikzpicture}

\begin{axis}[width=5in,axis equal image,
    axis lines=middle,
    xmin=-5,xmax=5,
    ymin=-1.5,ymax=5,
    restrict y to domain=-1.5:5,
    enlargelimits={abs=0.5cm},
    xtick={\empty},ytick={\empty},
    axis line style={latex-latex},
    xlabel=$x$,ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

%A triangle is drawn on the Cartesian plane. One side of the triangle is along
%the positive x-axis, and another side of the triangle is drawn in Quadrant II.
\coordinate (A) at (0,0);
\coordinate (B) at (3.5,0);
\coordinate (C) at (120:5);
\draw[red] (A) -- (B) -- (C) -- cycle;

%The labels for A and B are typeset.
\node at ({2.5mm*sqrt(2)/2}:{-2.5mm*sqrt(2)/2}){$A$};
\node at (3.5,-2.5mm){$B$};

%The point C' = C is placed using Cartesian coordinates.
\coordinate (C') at (-2.5,{5*sin(120)});
\draw[fill] (C') circle (1.5pt);
\draw (A) -- (C');
\draw (B) -- (C');
%The label for C' = C is typeset.
\coordinate (label_C_left) at ($(C')!-4mm!(B)$);
\coordinate (label_C_right) at ($(C')!-4mm!(A)$);
\coordinate (label_C) at ($(label_C_left)!0.5!(label_C_right)$);
\node[blue] at ($(C')!2.5mm!(label_C)$){$C$};

%Angles are drawn for $\theta$ and its supplement.
\draw[draw=blue] (A) ++(120:4mm) arc (120:0:4mm);
\coordinate (label_for_theta) at (60:6.5mm);
\node[font=\footnotesize] at (label_for_theta){$\theta$};
\draw[draw=blue,dash dot] (A) ++(180:6mm) arc (180:120:6mm);
\coordinate (label_for_supplement_to_theta) at (150:8.5mm);
\node[font=\footnotesize] at (label_for_supplement_to_theta){$\pi - \theta$};


%A right-angle mark is drawn.
\coordinate (U) at ($(-2.5,0)!3mm!45:(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(C')$);


\draw[dashed] (C') -- (-2.5,0);

%Braces indicating the distances that C' is from the axes are typeset. To give
%them the appearance of being typeset over the axes, they are first typeset
%in white with a line width of 2pt, which is 10 times the thickness of the
%brace that is actually typeset.
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);


\coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
\node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
\coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
\node at (label_for_5_cos_theta){$r\cos\theta$};

\end{axis}
\end{tikzpicture}


\end{document}
17
  • I see C in quadrant II (upper left). Jul 23, 2015 at 22:59
  • @John Kormylo It looks like that. I correctly put C there with the command \coordinate (C') at (-2.5,{5*sin(120)});.
    – user74973
    Jul 23, 2015 at 23:07
  • Is this really minimal? For example, why do you need multiple examples of coordinates being misplaced? Isn't one enough?
    – cfr
    Jul 23, 2015 at 23:16
  • Your example needs to demonstrate the problem....
    – cfr
    Jul 23, 2015 at 23:19
  • @cfr The A, \theta, and \pi - \theta are obviously in the wrong place. Also, the command \draw[red] (A) -- (B) -- (C) -- cycle; should draw a triangle in Quadrant III. It does when my computer compiles the code.
    – user74973
    Jul 23, 2015 at 23:25

5 Answers 5

4

You cannot straightforwardly use dimensions when specifying coordinates within an axis environment. Since the specification for C doesn't use a dimension, it is correctly placed, but other coordinates are misplaced relative to the intended origin.

To see that this is not an effect of TikZ itself, simply remove the axis environment and typeset the remaining code within the raw tikzpicture environment.

The reason this does not work in the axis environment is because there is, in general, no one-one correspondence between the coordinate systems used by TikZ and those configured by pgfplots. See page 350, section 4.27 TikZ Interoperability for details.

One option is to simply dispense with pgfplots as you are not really using it except to draw the axes:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usetikzlibrary{calc,arrows.meta,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}

\begin{tikzpicture}
  \draw [{Latex[]}-{Latex[]}] (-5.5,0) -- (5.5,0) node [below right] {$x$};
  \draw [{Latex[]}-{Latex[]}] (0,-1.5) -- (0,5.5) node [above right] {$y$};

  %A triangle is drawn on the Cartesian plane. One side of the triangle is along
  %the positive x-axis, and another side of the triangle is drawn in Quadrant II.
  \coordinate (A) at (0,0);
  \coordinate (B) at (3.5,0);
  \coordinate (C) at (120:5);
  \draw[draw=red] (A) node [below right] {$A$} -- (B) -- (C) -- cycle;

  %The label for B is typeset.
  \node at (3.5,-2.5mm){$B$};

  %The point C' = C is placed using Cartesian coordinates.
  \coordinate (C') at (-2.5,{5*sin(120)});
  \draw[fill] (C') circle (1.5pt);
  \draw (A) -- (C');
  \draw (B) -- (C');
  %The label for C' = C is typeset.
  \coordinate (label_C_left) at ($(C')!-4mm!(B)$);
  \coordinate (label_C_right) at ($(C')!-4mm!(A)$);
  \coordinate (label_C) at ($(label_C_left)!0.5!(label_C_right)$);
  \node[blue] at ($(C')!2.5mm!(label_C)$){$C$};

  %Angles are drawn for $\theta$ and its supplement.
  \draw[draw=blue] (A) ++(120:4mm) arc (120:0:4mm);
  \coordinate (label_for_theta) at (60:6mm);
  \node[font=\footnotesize] at (label_for_theta){$\theta$};
  \draw[draw=blue,dash dot] (A) ++(180:6mm) arc (180:120:6mm);
  \coordinate (label_for_supplement_to_theta) at (150:9.5mm);
  \node[font=\footnotesize] at (label_for_supplement_to_theta){$\pi - \theta$};

  %A right-angle mark is drawn.
  \coordinate (U) at ($(-2.5,0)!3mm!45:(A)$);
  \draw[dash dot] (U) -- ($(-2.5,0)!(U)!(A)$);
  \draw[dash dot] (U) -- ($(-2.5,0)!(U)!(C')$);

  \draw[dashed] (C') -- (-2.5,0);

  %Braces indicating the distances that C' is from the axes are typeset. To give
  %them the appearance of being typeset over the axes, they are first typeset
  %in white with a line width of 2pt, which is 10 times the thickness of the
  %brace that is actually typeset.
  \draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
  \draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
  \draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
  \draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);

  \coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
  \node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
  \coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
  \node at (label_for_5_cos_theta){$r\cos\theta$};
\end{tikzpicture}
\end{document}

non-plotted axes

Another option is to specify the coordinates differently. Although polar coordinates using absolute dimensions do not work within the axis environment you've defined, specifying them without using absolute dimensions does:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[width=5in,axis equal image,
    axis lines=middle,
    xmin=-5,xmax=5,
    ymin=-1.5,ymax=5,
    restrict y to domain=-1.5:5,
    enlargelimits={abs=0.5cm},
    xtick={\empty},ytick={\empty},
    axis line style={latex-latex},
    xlabel=$x$,ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]

    %A triangle is drawn on the Cartesian plane. One side of the triangle is along
    %the positive x-axis, and another side of the triangle is drawn in Quadrant II.
    \draw [draw= red] (0,0) coordinate (A) node [below right] {$A$} -- (3.5,0) coordinate (B) node [below] {$B$} -- (120:5) coordinate (C) -- cycle;

    %The point C' = C is placed using Cartesian coordinates.
    \draw (A) --  (-2.5,{5*sin(120)}) coordinate (C') -- (B);
    \draw[fill] (C') circle (1.5pt);
    %The label for C' = C is typeset.
    \coordinate (label_C_left) at ($(C')!-4mm!(B)$);
    \coordinate (label_C_right) at ($(C')!-4mm!(A)$);
    \coordinate (label_C) at ($(label_C_left)!0.5!(label_C_right)$);
    \node[blue] at ($(C')!2.5mm!(label_C)$){$C$};

    %Angles are drawn for $\theta$ and its supplement.
    \draw[draw=blue] (120:0.4) arc (120:0:0.4);
    \coordinate (label_for_theta) at (60:0.4);
    \node[font=\footnotesize, anchor=south west] at (label_for_theta){$\theta$};
    \draw[draw=blue,dash dot] (180:.6) arc (180:120:.6);
    \coordinate (label_for_supplement_to_theta) at (150:.6);
    \node[font=\footnotesize, anchor=south east] at (label_for_supplement_to_theta){$\pi - \theta$};

    %A right-angle mark is drawn.
    \draw[dash dot] ($(-2.5,0)!3mm!45:(A)$) coordinate (U) -- ($(-2.5,0)!(U)!(A)$);
    \draw[dash dot] (U) -- ($(-2.5,0)!(U)!(C')$);

    \draw[dashed] (C') -- (-2.5,0);

    %Braces indicating the distances that C' is from the axes are typeset. To give
    %them the appearance of being typeset over the axes, they are first typeset
    %in white with a line width of 2pt, which is 10 times the thickness of the
    %brace that is actually typeset.
    \draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
    \draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
    \draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
    \draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);

    \coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
    \node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
    \coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
    \node at (label_for_5_cos_theta){$r\cos\theta$};

  \end{axis}
\end{tikzpicture}
\end{document}

non-dimensions in polar coordinates

It is true that you can usually use dimensions to say e.g. (60:6mm) in an ordinary tikzpicture environment.

12
  • You have $\p - \theta$ in the wrong place. Yes, this is the display (or close to the display) that I wanted. The reason for my post was to ask for an explanation for TikZ misinterpreting the command \node at ({2.5mm*sqrt(2)/2},{-2.5mm*sqrt(2)/2}){$A$}; to place the label A and the two commands \coordinate (label_for_theta) at (60:4mm); and \node[font=\footnotesize] at (label_for_theta){$\theta$}; to place the label $\theta$.
    – user74973
    Jul 24, 2015 at 0:02
  • Yep. The second position should be (150:6mm). (I will edit the code.) I replaced 6mm with 0.6 and got something bizarre - elliptical with a major axis of about 10.
    – user74973
    Jul 24, 2015 at 0:13
  • I will look at your code now. I would prefer not to use the axis environment for such displays. Can you tell me the exact position that the x is typeset in the command xlabel style={at={(ticklabel* cs:1)},anchor=north west} and the exact position that the y is typeset in the command ylabel style={at={(ticklabel* cs:1)},anchor=south west}? I do not know what the manual is saying about ticklabel*.
    – user74973
    Jul 24, 2015 at 0:25
  • As I said, I would like to remove the axis environment. If I were to replace the x-axis in the axis environment with the command \draw[latex-latex] (-5,0) -- (5,0);, what would I put for blah in the command \node at (blah){$x$}, and if I were to replace the y-axis in the axis environment with the command \draw[latex-latex] (0,-5) -- (0,5);, what would I put for blah-blah in the command \node at (blah-blah){$y$}?
    – user74973
    Jul 24, 2015 at 0:35
  • What I would like to have in my code looks like this. \coordinate (x-label) at ($(5,0) +(x-shift,y-shift)$); and \node at (x-label){$x$};. What would be the x-shift and y-shift?
    – user74973
    Jul 24, 2015 at 0:44
5

Is this the image you are after?

enter image description here

After all the discussions and conversations, I think you now got the idea why there were some points misplaced. In brief, that is because the axes are basically used for plotting data points (table) and not dimensions and lengths. So, some conversions are required, e.g., the dimension 6mm may be entered 0.6, etc.

So, my suggestion is to drop the axis environment all together (since you used it only for drawing two axes) and you can draw the axes with a single line of code as this:

\path[<->](0,5)edge(0,-1.5cm)node[above right]{$y$}  (5,0)edge(-5,0)node[below right]{$x$};

I also cleaned the code a bit and removed extra unneeded points:

\documentclass{amsart}
\usepackage{amsmath,amsfonts,tikz}
\usetikzlibrary{calc,positioning,quotes,decorations.pathreplacing}
\begin{document}

\begin{tikzpicture}[>=latex]
% The axes:
\path[<->] (0,5)edge(0,-1.5cm)node[above right]{$y$}  (5,0)edge(-5,0)node[below right]{$x$};

%A triangle is drawn on the Cartesian plane. One side of the triangle is along the positive x-axis, and another side of the triangle is drawn in Quadrant II.
\path (0,0) coordinate (A) node[anchor=north west]{$A$}
(3.5,0)  coordinate (B) node[below]{$B$} 
(120:5)  coordinate (C) node[blue,above left]{$C$};
\draw[red] (A)--(B)--(C)--cycle;

%The point C' = C is placed using Cartesian coordinates.
\coordinate (C') at (-2.5,{5*sin(120)});
\draw[fill] (C') circle (1.5pt);
\draw (A) --(C');
\draw (B) --(C');

%Angles are drawn for $\theta$ and its supplement.
\draw[draw=blue] (120:4mm) arc (120:0:4mm);
\coordinate (label_for_theta) at (60:4mm);
\node[font=\footnotesize, anchor=south west] at (label_for_theta){$\theta$};
\draw[draw=blue,dash dot] (180:6mm) arc (180:120:6mm);
\coordinate (label_for_supplement_to_theta) at (150:6mm);
\node[font=\footnotesize,anchor=south east] at (label_for_supplement_to_theta){$\pi - \theta$};

%A right-angle mark is drawn.
\coordinate (U) at ($(-2.5,0)!3mm!45:(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(C')$);

\draw[dashed] (C') -- (-2.5,0);

% Braces indicating the distances that C' is from the axes are typeset. To give
% them the appearance of being typeset over the axes, they are first typeset
% in white with a line width of 2pt, which is 10 times the thickness of the
% brace that is actually typeset.
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=4pt,amplitude=5pt}] (-2.5,0) -- (C');
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C');
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=4pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);

\coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
\node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
\coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
\node at (label_for_5_cos_theta){$r\cos\theta$};
\end{tikzpicture}

\end{document}

My recommendation, however, is to use the specific packages and commands for your problem. Namely, tkz-euclide package is specialized in drawings like this. You will have the power to do many things easily with a single command like \tkzMarkRightAngle(p1,p2,p3), for example, to mark a right angle. See this full documentation of the package here (in French).

Here is my implementation with tkz-euclide (observe how short and clean this is):

\documentclass{standalone}
\usepackage{amsmath,tkz-euclide}
\usetikzlibrary{calc,positioning}
\usetkzobj{all} % To have full access to the power of tikz-euclide
\begin{document}

\begin{tikzpicture}[>=latex]
% The axes:
\path[<->] (0,5)edge(0,-1.5cm)node[above right]{$y$}  (5,0)edge(-5,0)node[below right]{$x$};    
% A triangle is drawn on the Cartesian plane. One side of the triangle is along
% the positive x-axis, and another side of the triangle is drawn in Quadrant II.
\path (0,0) coordinate (A) node[anchor=north west]{$A$} (3.5,0)  coordinate (B) node[below]{$B$} (120:5)coordinate(C) node[blue,above left]{$C$};
\draw[red] (A) -- (B) -- (C) -- cycle;

% The point C' = C is placed using Cartesian coordinates.
\coordinate (C') at (-2.5,{5*sin(120)});
\coordinate (A') at (-2.5,0);
\draw[fill] (C') circle (1.5pt);
\draw (A)--(C')--(B)--cycle;

% Angles:
\tkzMarkAngle[label=$\theta$,dist=.6,size=0.4,font=\footnotesize](B,A,C)
\tkzMarkAngle[dash dot,label=$\pi-\theta$,dist=0.95,size=0.6,font=\footnotesize](C,A,A')
\tkzMarkRightAngle(C,A',A)
\draw[dashed] (C')--(A');

% Braces indicating the distances that C' is from the axes are typeset. To give
% them the appearance of being typeset over the axes, they are first typeset
% in white with a line width of 2pt, which is 10 times the thickness of the
% brace that is actually typeset.    
\draw[white,line width=5pt,decorate,decoration={brace,raise=4pt,amplitude=5pt}] (A')--(C');
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (A')--(C');
\draw[white,line width=5pt,decorate,decoration={brace,raise=4pt,amplitude=5pt,mirror}] (A')--(A);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (A')--(A);

\coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
\node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
\coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
\node at (label_for_5_cos_theta){$r\cos\theta$};
\end{tikzpicture}

\end{document}

enter image description here

16
  • Switch $\theta$ and $\pi - \theta$ and have $\pi - \theta$ at 6mm. I really want to know why the commands that I have for placing A, and the two angles are misinterpreted.
    – user74973
    Jul 23, 2015 at 23:57
  • Replace 4mm with 6mm in your command \draw[draw=blue,dash dot] (A) ++(180:4mm) arc (180:120:4mm);.
    – user74973
    Jul 24, 2015 at 0:06
  • You are right. I just edited my code to have \coordinate (label_for_theta) at (60:6.5mm); and \coordinate (label_for_supplement_to_theta) at (150:8.5mm);.
    – user74973
    Jul 24, 2015 at 0:16
  • Why are the commands that I have for placing A and the two angles misinterpreted?
    – user74973
    Jul 24, 2015 at 0:18
  • 1
    @user74973 It is \coordinate (x-label) at ($(5,0) +(.3333em,-.3333em)$); Unless you set inner sep=another value, so, it is equal to the inner sep (which is initially .3333em).
    – AboAmmar
    Jul 24, 2015 at 0:56
3

Another short solution (run with latex --> dvips --> ps2pdf):

\documentclass[pstricks,border=10pt]{standalone}
\usepackage{pst-eucl,pst-plot}
\def\iTheta{120} \def\Radius{5} \def\Pb{4}

\begin{document}

\begin{pspicture}(-5,-1.5)(6.6,6)
  \psaxes[ticks=none,labels=none,linecolor=black!40]{<->}(0,0)(-5,-1.5)(6.2,5.5)[$x$,0][$y$,90]
  \pstTriangle[linewidth=1.5pt,linejoin=2](0,0){A}(\Pb,0){B}(\Radius;\iTheta){C} 
  \pstGeonode[PointSymbol=none,PointName=none](C|{0,0}){C'}
  \psline[linestyle=dashed](C)(C')\pstRightAngle[linestyle=dashed]{C}{C'}{A}
  \pstMarkAngle[MarkAngleRadius=0.6]{B}{A}{C}{$\theta$}
  \pstMarkAngle[MarkAngleRadius=0.6,linestyle=dotted]{C}{A}{C'}{$\pi-\theta$}
  \psbrace[ref=c,nodesepB=5pt,rot=90,braceWidth=0.5pt](C')(A){$r\cos\theta$}
  \psbrace[ref=r,nodesepA=-5pt,rot=180,braceWidth=0.5pt](C)(C'){$r\sin\theta$}
\end{pspicture}

\end{document}

enter image description here

1

Keeping it fairly simple...

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{quotes,angles,arrows.meta,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[>=Latex, line join=round,
  brace/.style={decorate, decoration={brace, raise=5pt, amplitude=5pt}}]
\draw [help lines, <->] (-4,0) -- (4,0) node [at end, right] {$x$};
\draw [help lines, <->] (0,-1) -- (0,4) node [at end, right] {$y$};
\path (0,0) coordinate (A) (3,0) coordinate (B) (120:4) coordinate (C);
\draw (A) node [below right] {$A$} -- (B) node [below right] {$B$} -- 
      (C) node [above left]  {$C$} -- cycle;
\fill (C) circle [radius=1pt];
\draw [dashed] (C) -- (C |- A) coordinate (C');
\pic ["$\theta$", draw, angle eccentricity=1.5] {angle=B--A--C};
\pic ["$\pi-\theta$", draw, densely dotted, angle eccentricity=2] 
  {angle=C--A--C'};
\draw [dashed] (C') ++(0,0.25) -| ++(0.25, -0.25);
\draw [brace] (A)  -- (C') node [midway, below=10pt] {$r\cos\theta$};
\draw [brace] (C') -- (C)  node [midway, left=10pt]  {$r\sin\theta$};
\end{tikzpicture}
\end{document}

enter image description here

1

A PSTricks solution where the drawing is adjusted according to value of \Angle (which is denoted \theta on the drawing):

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{xfp}

%%% Parameter %%%
\def\Angle{120} % angle (calculated counterclockwise), measured in degrees, with \Angle != 90

\begin{document}

\begin{pspicture}(-5,-1.5)(6.6,6)
  % points
  \pnodes{P}(0,0)(5,0)(\fpeval{5*cos(\Angle*pi/180)},\fpeval{5*sin(\Angle*pi/180)})(\fpeval{5*cos(\Angle*pi/180)},0)
  % axes
  \psaxes[ticks = none, labels = none]{->}(0,0)(-5,-1.5)(6.2,5.5)[$x$,0][$y$,90]
  % vertices
  \psdots(P1)(P2)
  % triangle
  \psline(P1)(P2)(P0)
  % projection onto x-axis
  \psline[linestyle = dashed, dash = 3pt 2pt](P2)(P3)
  % names of vertices
  \uput[270](P1){$B$}
  \uput[\Angle](P2){$C$}
\ifdim \Angle pt > 90 pt
  \uput[315](P0){$A$}
  \psbrace[ref = c, rot = 90, nodesepB = 5pt, braceWidth = \pslinewidth](P3)(P0){$r\cos\theta$}
  \psbrace[ref = r, rot = 180, nodesepA = -5pt, braceWidth = \pslinewidth](P2)(P3){$r\sin\theta$}
\else
  \uput[225](P0){$A$}
  \psbrace[ref = c, rot = 90, nodesepB = 5pt, braceWidth = \pslinewidth](P0)(P3){$r\cos\theta$}
  \psbrace[ref = r, nodesepA = 30pt, braceWidth = \pslinewidth](P3)(P2){$r\sin\theta$}
\fi
  % angles
  \psarc(P0){0.5}{0}{\Angle}
  \uput{0.6}[\fpeval{\Angle/2}](P0){$\theta$}
  \psarc[linestyle = dashed, dash = 3pt 2pt](P0){0.5}{\Angle}{180}
  \uput{0.5}[\fpeval{(\Angle+180)/2}](P0){$\pi - \theta$}
\end{pspicture}

\end{document}

output

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.