3

I am trying to draw a figure similar to this one enter image description here

This is the code for that figure that I've done so far

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}

\begin{document}

\begin{tikzpicture}
    %coordinate system
    \draw[thick,->] (0,-5) -- (0,5)node[above left]{$y$};
    \draw[thick,->] (-5,0) -- (5,0)node[below right]{$x$};
    
%circle
\draw (4,0) arc (0:360:4)node[ below]{$ $};

%dots % their lines
\draw[red] (0,0) -- (2.8,2.9)  node[circle,red,fill,inner sep=3pt]{} node[above right]{$Q=(\cos v,\sin v)$};

\draw[blue] (0,0) -- (-2.8,2.9)  node[circle,blue,fill,inner sep=3pt]{} node[above left]{$P=(\cos u,\sin u)$};

%line joining both dots
\draw[magenta] (-2.8,2.9) -- (2.8,2.9) node[midway, above left ]{$d$};

%angles
\draw (2,0) arc (0:134:2)node[midway,above right]{$u $};

\draw (1,0) arc (0:45:1)node[midway,above right]{$v $};

\end{tikzpicture}

\end{document}

How can I draw the arrows for the direction of the angles?

And also how can I add the label for the circle, it's supposed to be a unit circle, I wanted to draw an arrow indicating that the equation $x^2+y^2=1$ is that circle.

Could someone please help?

Thank you in advance.

Edit.

The label for the circle without arrow: %circle \draw (4,0) arc (0:360:4)node[very near end, below right]{$x^2+y^2=1$};

Edit2.

So far, the image is this, which looks decent :) I think.

enter image description here

4
  • You seem to have uploaded an image of the output of the code in the question, did you intend to upload a different image, with something like the desired output? For the second question, do you mean you want a node with that equation, and an arrow from the node to the circle? Commented Aug 2, 2020 at 22:21
  • @TorbjørnT. no, I meant that image; I don't have the intended image at hand but that's the idea. For the second question, yes that's what I meant. Commented Aug 2, 2020 at 22:30
  • 1
    If the direction of the angle is unclockwise, you should write \draw[->] (2,0) arc... and \draw[->] (1,0) arc.... If it is clockwise, the change to [<-]. Finally if it is in both directions, write [<->].
    – Cragfelt
    Commented Aug 2, 2020 at 22:36
  • @Cragfelt ooh so that easy, I thought it was going to be very difficult, thank you! Commented Aug 2, 2020 at 22:41

1 Answer 1

5

Arrow tips for arcs are added the same way as arrow tips to other paths, so do exactly the same as you did for the axes: [->]

For the equation: add the node with e.g. \node (eq) at (x,y) {...}; with suitable values for x and y, or \node (eq) at (angle:radius) {...}; to use polar coordinates instead of Cartesian coordinates. Having named the node eq, you can draw an arrow from it to the circle with e.g. \draw [->] (eq) -- (-20:4);, again using polar coordinates.

In the code below I used polar coordinates to place the P and Q nodes as well, and included a style for the dots, and used labels for the P/Q labels. Obviously your method with a second node works fine as well, so this is mostly a matter of personal preference I guess. Polar coordinates are quite convenient in this case though. Oh, and I used the circle construct to make the circle instead of an arc.

enter image description here

\documentclass{article}%
\usepackage[utf8]{inputenc}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[dot/.style={circle,fill,inner sep=3pt, outer sep=0}]

%coordinate system
\draw[thick,->] (0,-5) -- (0,5) node[above left]{$y$};
\draw[thick,->] (-5,0) -- (5,0) node[below right]{$x$};
    
%circle
\draw (0,0) circle[radius=4cm];

%dots 
\path [red]  (45:4)  node[dot, label={above right:{$Q=(\cos v,\sin v)$}}] (p) {};
\path [blue] (135:4) node[dot, label={above left:{$P=(\cos u,\sin u)$}}] (q) {};

%line joining dots
\draw[magenta] (p) -- (q) node[midway, above left ]{$d$};
\draw [red]    (0,0) -- (p);
\draw [blue]   (0,0) -- (q);

%angles
\draw [->] (2,0) arc (0:135:2) node[midway,above right] {$u$};
\draw [->] (1,0) arc (0:45:1)  node[midway,above right] {$v$};

\node (eq) at (-10:6cm) {$x^2 + y^2 = 1$};    
\draw [->] (eq) to[bend left] (-30:4);

\end{tikzpicture}

\end{document}
4
  • Thank you sir for your answer, looks very elegant and I've understood it Commented Aug 3, 2020 at 16:04
  • How can I change the position of the text {$u$} and {$v$} labeling the angles? Say modifying u more to the right? Commented Aug 3, 2020 at 17:59
  • 1
    @IlikeThatMeow Perhaps using pos=0.45 or nearby value instead of midway. Or if you want just small horizontal shift, add xshift=3pt to the node options. Commented Aug 3, 2020 at 18:05
  • Got it, thank you. Commented Aug 3, 2020 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .