6

I have two rays drawn with a common endpoint at A. I mark a point 3/7 of the way from A to the end of one of the rays, and label it P. I want to draw a circular arc centered at A through P between the rays.

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

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


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


\begin{document}


\begin{tikzpicture}

%Three points are labeled in the Cartesian plane.
\coordinate (A) at (0,0);
\coordinate (B) at (75:3);
\coordinate (C) at ($(B) +(5,0)$);

%Two rays are drawn
\draw[name path=path_AB, -latex] (A) -- (B);
\draw[name path=path_AC, -latex] (A) -- (C);

%The four vertices are labeled.
\node at ($(A)! -2.5mm! (C)$){$A$};
\node at ($(B)! -2.5mm! (A)$){$k$};
\node at ($(C)! -2.5mm! (A)$){$\ell$};

%The circular arc centered at A starts at P.
\coordinate (P) at ($(A)!3/7!(B)$);
\draw[fill] (B') circle (1.5pt);


%An arc between the rays starting at P.

\end{tikzpicture}

\end{document}

2 Answers 2

6

Updated

Since you already defined P, you can calculate the length that goes from A to it and then use the updated version of the command you see in the old solution:

%An arc between the rays starting at P.
\pgfmathsetlengthmacro{\radius}{(3/7)*3cm}
\draw (P) arc (80:30:\radius) node[pos=0,left] {$P$};

figure 1

Old solution

If you don't have a point already, as in your case, you can just add this to your code:

\draw ++(75:1) arc (75:27:1) node[pos=0,left] {$P$};

which does:

  • Start from (0,0) (the A coordinate) and move 1 in the direction of the 75 angle
  • From there, draw an arc that goes from the angle 75 to the angle 27.1 is the radius.
  • Finally, add a node P at the start of the arc, on the left.

figure 2

Some explanations

Is the part ++(75:1) compiled the same as (0,0) ++(75:1)?

Yes, it's the same thing.

Why do you have 27 in (75:27:1)?

75 is the starting angle, while 27 is the end angle. These angles are not the angle at which the path exits or enters, here's an image to show what I mean:

figure 3

16
  • The point P is already given. The desired arc has to pass through P. You answer locates another point P in a position that differs from the actual position of the already existing P. Commented Jul 1, 2015 at 20:42
  • @GonzaloMedina Ops. Didn't see that. I'll fix the answer.
    – Alenanno
    Commented Jul 1, 2015 at 21:31
  • @Alenanno I am not familiar with \pgfmathsetlengthmacro command. Why can't you have \draw (P) arc (80:30:(3/7)*3cm)?
    – user74973
    Commented Jul 1, 2015 at 22:22
  • 1
    @user74973 Actually you can, but you need to write it like arc (80:30:{(3/7)*3cm}), with curly braces.
    – Alenanno
    Commented Jul 1, 2015 at 22:48
  • 1
    @user74973 The \pgfmathsetlengthmacro is useful in case you want to reuse the same value, then you just type \radius or whatever name you decide.
    – Alenanno
    Commented Jul 1, 2015 at 22:50
11

Two options.

  1. Clipping a circle using the rays:

    \begin{scope}
    \clip (B) -- (A) -- (C);
    \path[draw] 
      let
      \p1=( $ (A) - (P) $ )
      in
      (A) circle ({veclen(\x1,\y1)});
    \end{scope}
    
  2. using the angles library:

    \path[draw] 
      let
      \p1=( $ (A) - (P) $ )
      in
      pic[draw,angle radius={veclen(\x1,\y1)}] {angle = C--A--B};
    \end{tikzpicture}
    

In both cases, the calc library was used to calculate the radius.

The complete code:

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

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


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


\begin{document}


\begin{tikzpicture}

%Three points are labeled in the Cartesian plane.
\coordinate (A) at (0,0);
\coordinate (B) at (75:3);
\coordinate (C) at ($(B) +(5,0)$);

%Two rays are drawn
\draw[name path=path_AB, -latex] (A) -- (B);
\draw[name path=path_AC, -latex] (A) -- (C);

%The four vertices are labeled.
\node at ($(A)! -2.5mm! (C)$){$A$};
\node at ($(B)! -2.5mm! (A)$){$k$};
\node at ($(C)! -2.5mm! (A)$){$\ell$};

%The circular arc centered at A starts at P.
\coordinate (P) at ($(A)!3/7!(B)$);
%\draw[fill] (B') circle (1.5pt);

\node[left] at (P) {$P$};

\begin{scope}
\clip (B) -- (A) -- (C);
\path[draw] 
  let
  \p1=( $ (A) - (P) $ )
  in
  (A) circle ({veclen(\x1,\y1)});
\end{scope}

\path[draw] 
  let
  \p1=( $ (A) - (P) $ )
  in
  pic[draw,angle radius={veclen(\x1,\y1)}] {angle = C--A--B};
\end{tikzpicture}

\end{document}

The result:

enter image description here

5
  • This is the display that I wanted. I am not familiar with let. I will refer to the manual. Please explain {veclen(\x1,\y1)}.
    – user74973
    Commented Jul 1, 2015 at 16:33
  • 1
    @user74973 veclen(a,b) is a PGF math function which calculates \sqrt{a^2 + b^2}; in this case, I used it to calculate the length of the segment from "A" to "P", since \x1 and \y1 are the x and y coordinates, respectively, of the point A-P . Commented Jul 1, 2015 at 16:38
  • I just looked in http://www.bu.edu/math/files/2013/08/tikzpgfmanual.pdf for a discussion of let. I didn't see it. May you suggest a web site for it?
    – user74973
    Commented Jul 1, 2015 at 16:41
  • 2
    @user74973 Always refer to CTAN for up-to-date documentation: PGF manual, Section 14.15 The Let Operation. Commented Jul 1, 2015 at 16:43
  • 1
    Option 1b: Clipping and then \node[draw] at (A) [circle through=(P)]{}; (The math is the same, just the interface is different.) Needs the through library, though. Commented Jul 1, 2015 at 20:58

You must log in to answer this question.

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