2

I have a diagram of part of a circle centered at the origin, an angle marked "alpha," a radius, and two line segments having an endpoint on the x-axis. It should have the following two modifications. (The first modification involves use of the overlay command.)

As displayed in the diagram, the label (or node) "P = (r\cos\alpha, \, r\sin\alpha)" interferes with the dashed line segment between the x-axis and Q. It should be in a rectangular node over this line segment. (If the label is put in the north west position with respect to P, it should be in a rectangular node over the circle.)

The angle \alpha should be midway along the arc.

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

\begin{document}


\begin{center}
\begin{tikzpicture}[
dot/.style={
fill,
circle,
inner sep=1.5pt
}
]
\clip (-1,-1) rectangle (7,7);
\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);
\path[dashed] (0,0) -- (\ang:7);
\draw[dashed] (0,0) -- (4,4.76701437);
\draw[dashed] (4,0) -- (4,4.76701437);
\draw[dashed] (2.5711504,0) -- (2.5711504,3.06417777);
\node[dot,label={right:$P=(r\cos\alpha, \, r\sin\alpha)$}] at (2.5711504,3.06417777) {};
\node[dot,label={right:$Q=(r, \, r\tan\alpha)$}] at (4,4.76701437) {};
\draw[->] (0,0) --node[pos=1.25,above]{$\alpha$} (0.8,0) arc (0:\ang:0.8cm) ;


\path[name path=linec] (2,0) -- (2,3); 
\draw[name intersections={of=lineb and linec, by={c}},thick]{};
\end{tikzpicture}
\end{center}

\end{document}
4

For the first question (label interfering with the dashed line), you could use every label/.style to define a white background for the label.

For the second (\alpha should be midway along the arc), you could use another arc with half the angle and a slightly larger radius.

The result:

\documentclass{article}%
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\def\ang{50} % 0< \ang<90

\begin{document}


\begin{center}
\begin{tikzpicture}[
dot/.style={
fill,
circle,
inner sep=1.5pt
},
every label/.style={fill=white},
]
\clip (-1,-1) rectangle (7,7);
\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);
\path[dashed] (0,0) -- (\ang:7);
\draw[dashed] (0,0) -- (4,4.76701437);
\draw[dashed] (4,0) -- (4,4.76701437);
\draw[dashed] (2.5711504,0) -- (2.5711504,3.06417777);
\node[dot,label={right:$P=(r\cos\alpha, \, r\sin\alpha)$}] at (2.5711504,3.06417777) {};
\node[dot,label={right:$Q=(r, \, r\tan\alpha)$}] at (4,4.76701437) {};
\draw[->] (0.8,0) arc [start angle=0, end angle=\ang, radius=0.8cm] ;
\path (1.0,0) arc [start angle=0, end angle=25, radius=1.0cm] node {$\alpha$};


\path[name path=linec] (2,0) -- (2,3); 
\draw[name intersections={of=lineb and linec, by={c}},thick]{};
\end{tikzpicture}
\end{center}

\end{document}

enter image description here

4

In Metapost you can have all those sine and cosine values worked out for you with the rotated operator, and the z$=(x$,y$) convention comes in handy. Clearing the box behind the label requires a little more work, as shown below and as explained in section 9 of the manual.

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

r := 100;     % radius of the arc
alpha := 50;  % angle of rotation
margin := 24; % overshoot for the axes

z1 = (r,0) rotated alpha; % point P
z2 = (q,0) rotated alpha; % point Q, (q is just a dummy variable)
x2 = r;

drawoptions(dashed evenly);
draw origin -- z2;
draw (x1,0) -- z1;
draw (x2,0) -- z2;
draw subpath (-1, 3) of fullcircle scaled 2r
     cutbefore ((-margin,-margin) -- (r+margin,-margin))
     cutafter  ((-margin,-margin) -- (-margin,r+margin));
drawoptions();

% label the points
dotlabel.rt(btex $Q=(r, r\tan\alpha)$ etex, z2);
% dotlabel.rt(btex $P=(r\cos\alpha,r\sin\alpha)$ etex, z1);
% but this makes a mess of the lines, so do it by hand and unfill behind
fill fullcircle scaled dotlabeldiam shifted z1;
picture P; P = thelabel.rt(btex $P=(r\cos\alpha,r\sin\alpha)$ etex, z1+(6,0));
unfill bbox P; draw P;

% axes
drawarrow (0,-margin) -- (0,r+margin); label.rt (btex $y$ etex, (0,r+margin));
drawarrow (-margin,0) -- (r+margin,0); label.bot(btex $x$ etex, (r+margin,0));

% angle mark
path mark; mark = (20,0) { up } .. { up rotated alpha } (20,0) rotated alpha;
drawarrow mark; label.rt(btex $\alpha$ etex, point .5 of mark);

endfig;
end.
3

Since you are loading pgfplots I take it as a go signal for a pgfplots answer :) The nice part is you can be precise about the plots and place the nodes exactly where the label says. And you can use the angles library to mark the angle and it is more concise since you don't need to deal with the axes and no intersections needed. The con is that you need to be a little used to pgfplots coordinate system and axis options.

I placed the labels as the last things to be drawn so fill=white is sufficient. Also I think equations for coordinates are not so clean notation so converted it to a vector.

\documentclass{standalone}
\usepackage{pgfplots,mathtools}
\pgfplotsset{compat=1.10}
\usetikzlibrary{positioning,angles,quotes}

\def\myang{50} % 0< \ang<90
\def\myradius{3}
\begin{tikzpicture}[dot/.style={fill,circle,inner sep=1.5pt}]
\begin{axis}[axis lines=middle,xlabel=$x$,ylabel=$y$,
          xtick=\empty,ytick=\empty,
          xmax=\myradius*1.5,ymax=\myradius*1.5,
          axis equal,
          clip=false]
\addplot[dashed,domain=-pi/10:6*pi/10] ({\myradius*cos(deg(x))},{\myradius*sin(deg(x))});
%Place coordinates
  \coordinate (O) at (axis cs:0,0);
  \node[dot] at (axis cs:{\myradius*cos(\myang)},{\myradius*sin(\myang)}) (P) {};
  \node[dot] at (axis cs:{\myradius},{\myradius*tan(\myang)}) (Q) {};
  \draw[dashed] (O) -- (Q) -- (Q |- O) coordinate(Qp) (P) -- (P |- O);
% Mark the angle
  \pic["$\alpha$", draw,->,angle eccentricity=1.2,angle radius=1cm] {angle=Qp--O--Q};
% Place the node descriptions
  \node[fill=white,inner sep=1pt,right= 1.2 mm of P] 
      {$P\begin{psmallmatrix}r\cos\alpha\\ r\sin\alpha\end{psmallmatrix}$};
  \node[right= 1mm of Q] {$Q\begin{psmallmatrix}r\\ r\tan\alpha\end{psmallmatrix}$};

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

enter image description here

1

Here another solution using fill=white for the formula-labels. I also tried to pretty up the code and let the internals do the mathematics. If you need more information just ask.

Updated version - see history for changes

\documentclass[border=5mm, tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
 \tikzset{
    >=latex,
    dot/.style={
        fill,
        circle,
        inner sep=1.5pt,
    },
    axis/.style={
        ->,
        thick,
    },
    label/.style={
        right=.25cm,
        fill=white,
    },
 }

 % define angle and radius
 \newcommand{\myradius}{4cm}
 \newcommand{\myangle}{50}

 % x- and y-axis
 \draw [axis] (-.5,0) -- ++(6,0) node [below] {$x$};
 \draw [axis] (0,-.5) -- ++(0,6) node [right] {$y$};

 % arc with radius
 \draw [dashed] (0,0) + (-15:\myradius) arc (-15:105:\myradius);

 % coordinates of p and q
 \coordinate (p) at (\myradius * cos \myangle, \myradius * sin \myangle) node at (p) [dot] {};
 \coordinate (q) at (\myradius, \myradius * tan \myangle) node at (q) [dot] {};

 % lines from p and q 
 \draw [dashed] (q) -- (0,0);
 \draw [dashed] (q) -- (\myradius,0);
 \draw [dashed] (p) -- ($(0,0)!cos \myangle!(\myradius,0)$);

 % labels at p and q
 \node at (p) [label] {$P={r \cos \alpha \choose r \sin \alpha}$};
 \node at (q) [label] {$Q={r \choose r \tan \alpha}$};

 % alpha and r labels
 \draw [->] (.8,0) arc (0:\myangle:.8cm);
 \node at ($(0,0) + (\myangle/2:1cm)$) {$\alpha$};
 \draw [->] (0,0) -- ++(-5:\myradius) node [below left] {$r$}; 
\end{tikzpicture}
\end{document}

Rendered image: Rendered image

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.