3

I have the display for showing the identities for the sine and cosine of a difference of two numbers. It is drawn exactly as I want. I want to know why the following two commands do not draw the same line segment at the midpoint on an arc of a circle centered at Q. (The vector difference (Q)-(P) is in the first quadrant, and (Q)-(R) is in the second quadrant. Using atan to determine the angle of the vector (Q)-(R) requires one to add 180.) I give two commands for drawing this line segment. The one drawn in blue is the one I want, and the one drawn in green is misplaced. Why is the green line segment centered at Q? How do I change the syntax so that it is drawn where the blue line segment is drawn?

Here is the command that draws the blue line segment.

\draw[draw=blue,fill] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in
($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!-3pt!(Q)$) -- ($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!3pt!(Q)$);

Here is the command that draws the green line segment.

\draw[draw=green,fill] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in
($(Q) +({0.5*(\n1+\n2+180)}:{-0.5-5pt})$) -- ($(Q) +({0.5*(\n1+\n2+180)}:{-0.5+5pt})$);

I understand that there the angles package is designed for marking angles. I am using this as an opportunity to get familiar with the let - in syntax.

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

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


\begin{document}



\noindent \hspace*{\fill}
\begin{tikzpicture}

\coordinate (O) at (0,0);

\draw[-latex] (O) -- (10:3);
\coordinate (label_for_ray_r_1) at ($(10:3) +(10:3mm)$);
\node at (label_for_ray_r_1){$r_{1}$};
\draw[-latex,dashed] (O) -- (190:7);
\draw[-latex,name path=ray_2] (O) -- (130:9);
\coordinate (label_for_ray_r_2) at ($(130:9) +(130:0.3)$);
\node at (label_for_ray_r_2){$r_{2}$};
\draw[-latex,name path=ray_3] (O) -- (150:8);
\coordinate (label_for_ray_r_3) at ($(150:8) +(150:0.3)$);
\node at (label_for_ray_r_3){$r_{3}$};


\coordinate (Q) at (130:7.5);
\draw[fill] (Q) circle (1.5pt);
\coordinate (P) at ($(O)!(Q)!(150:8)$);
\draw[fill,blue] (P) circle (1.5pt);
\draw[name path=path_PQ] (P) -- (Q);

%A right-angle mark is drawn at P.
\coordinate (U) at ($(P)!4mm!45:(O)$);
\draw[dashed] (U) -- ($(P)!(U)!(O)$);
\draw[dashed] (U) -- ($(P)!(U)!(Q)$);


\coordinate (A) at ($(O)!(Q)!(190:4)$);
\coordinate (R) at ($(A)!(P)!(Q)$);
\draw[fill,blue] (R) circle (1.5pt);
\draw (P) -- (R);
\draw (Q) -- (R);
\draw (R) -- (A);

%A right-angle mark is drawn at R.
\coordinate (U_4) at ($(R)!4mm!45:(P)$);
\draw[dashed] (U_4) -- ($(R)!(U_4)!(Q)$);
\draw[dashed] (U_4) -- ($(R)!(U_4)!(P)$);


%The label for O is typeset. An invisible path is drawn 3mm below the line containing
%ray_1. Since the angle for y is between rays inclined at 130 degrees and 150 degrees,
%the label for O is centered along a ray inclined at an angle of -40 degrees.
\coordinate (label_for_O) at ($(0,0)!3mm!-90:(10:1)$);
\node at (label_for_O){$O$};

%The label for Q is typeset.
\coordinate (label_Q_left) at ($(Q)!-1cm!(A)$);
\coordinate (label_Q_right) at ($(Q)!-1cm!(P)$);
\coordinate (label_Q) at ($(label_Q_left)!0.5!(label_Q_right)$);
\node[blue] at ($(Q)!3mm!(label_Q)$){$Q$};

%The label for P is typeset.
\coordinate (label_P_above) at ($(P)!-15mm!(Q)$);
\coordinate (label_P_below) at ($(P)!-15mm!(R)$);
\coordinate (label_P) at ($(label_P_above)!0.5!(label_P_below)$);
\node[blue] at ($(P)!3mm!(label_P)$){$P$};

%The label for R is typeset.
\coordinate (label_R) at ($(R)!-4mm!(P)$);
\node[blue] at (label_R){$R$};



%The angle at O with a measure of 180 - x is drawn. The angle is marked with "|".
\draw[draw=blue] (O) ++(190:0.75) arc (190:150:0.75);
\draw[draw=blue] ($(170:0.75) +(170:-3pt)$) -- ($(170:0.75) +(170:3pt)$);

%The angle at O with a measure of y is drawn.
\draw[draw=blue] (O) ++(150:0.9) arc (150:130:0.9);
\coordinate (label_for_y) at (140:1.1);
\node[font=\footnotesize] at (label_for_y){$y$};

%An angle at P with measure x is drawn. The angle is marked with "|".
\draw[draw=blue] let \p1=($(R)-(P)$), \n1={atan(\y1/\x1)} in ($(P)!0.5cm!(O)$) arc (-30:\n1:0.5);
\draw[draw=blue] let \p1=($(R)-(P)$), \n1={atan(\y1/\x1)} in ($($(P) +({0.5*(\n1-30)}:0.5)$)!-3pt!(P)$) -- ($($(P) +({0.5*(\n1-30)}:0.5)$)!3pt!(P)$);

%An angle at Q with measure x is drawn. The angle is marked with "|".
\draw[draw=blue] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in ($(Q)!0.5cm!(R)$) arc (\n1:{\n2 - 180}:0.5);
\draw[draw=blue,fill] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in
($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!-3pt!(Q)$) -- ($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!3pt!(Q)$);

\draw[draw=green,fill] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in
($(Q) +({0.5*(\n1+\n2+180)}:{-0.5-5pt})$) -- ($(Q) +({0.5*(\n1+\n2+180)}:{-0.5+5pt})$);


\end{tikzpicture}

\end{document}
4

It's a problem of mixing units. Using simply ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5-5pt})$) PGF assumes unit is pt so it simply moves you -5.5pt away from Q (similarly, ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5+5pt})$) moves you just 4.5pt away from Q. What you need is to specify cm for the 0.5

\draw[draw=green,fill] 
  let 
  \p1=($(Q)-(R)$), 
  \n1={atan(\y1/\x1)}, 
  \p2=($(Q)-(P)$), 
  \n2={atan(\y2/\x2)} 
  in
  ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5cm-5pt})$) -- 
  ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5cm+5pt})$);

The complete code:

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

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


\begin{document}



\noindent \hspace*{\fill}
\begin{tikzpicture}

\coordinate (O) at (0,0);

\draw[-latex] (O) -- (10:3);
\coordinate (label_for_ray_r_1) at ($(10:3) +(10:3mm)$);
\node at (label_for_ray_r_1){$r_{1}$};
\draw[-latex,dashed] (O) -- (190:7);
\draw[-latex,name path=ray_2] (O) -- (130:9);
\coordinate (label_for_ray_r_2) at ($(130:9) +(130:0.3)$);
\node at (label_for_ray_r_2){$r_{2}$};
\draw[-latex,name path=ray_3] (O) -- (150:8);
\coordinate (label_for_ray_r_3) at ($(150:8) +(150:0.3)$);
\node at (label_for_ray_r_3){$r_{3}$};


\coordinate (Q) at (130:7.5);
\draw[fill] (Q) circle (1.5pt);
\coordinate (P) at ($(O)!(Q)!(150:8)$);
\draw[fill,blue] (P) circle (1.5pt);
\draw[name path=path_PQ] (P) -- (Q);

%A right-angle mark is drawn at P.
\coordinate (U) at ($(P)!4mm!45:(O)$);
\draw[dashed] (U) -- ($(P)!(U)!(O)$);
\draw[dashed] (U) -- ($(P)!(U)!(Q)$);


\coordinate (A) at ($(O)!(Q)!(190:4)$);
\coordinate (R) at ($(A)!(P)!(Q)$);
\draw[fill,blue] (R) circle (1.5pt);
\draw (P) -- (R);
\draw (Q) -- (R);
\draw (R) -- (A);

%A right-angle mark is drawn at R.
\coordinate (U_4) at ($(R)!4mm!45:(P)$);
\draw[dashed] (U_4) -- ($(R)!(U_4)!(Q)$);
\draw[dashed] (U_4) -- ($(R)!(U_4)!(P)$);


%The label for O is typeset. An invisible path is drawn 3mm below the line containing
%ray_1. Since the angle for y is between rays inclined at 130 degrees and 150 degrees,
%the label for O is centered along a ray inclined at an angle of -40 degrees.
\coordinate (label_for_O) at ($(0,0)!3mm!-90:(10:1)$);
\node at (label_for_O){$O$};

%The label for Q is typeset.
\coordinate (label_Q_left) at ($(Q)!-1cm!(A)$);
\coordinate (label_Q_right) at ($(Q)!-1cm!(P)$);
\coordinate (label_Q) at ($(label_Q_left)!0.5!(label_Q_right)$);
\node[blue] at ($(Q)!3mm!(label_Q)$){$Q$};

%The label for P is typeset.
\coordinate (label_P_above) at ($(P)!-15mm!(Q)$);
\coordinate (label_P_below) at ($(P)!-15mm!(R)$);
\coordinate (label_P) at ($(label_P_above)!0.5!(label_P_below)$);
\node[blue] at ($(P)!3mm!(label_P)$){$P$};

%The label for R is typeset.
\coordinate (label_R) at ($(R)!-4mm!(P)$);
\node[blue] at (label_R){$R$};



%The angle at O with a measure of 180 - x is drawn. The angle is marked with "|".
\draw[draw=blue] (O) ++(190:0.75) arc (190:150:0.75);
\draw[draw=blue] ($(170:0.75) +(170:-3pt)$) -- ($(170:0.75) +(170:3pt)$);

%The angle at O with a measure of y is drawn.
\draw[draw=blue] (O) ++(150:0.9) arc (150:130:0.9);
\coordinate (label_for_y) at (140:1.1);
\node[font=\footnotesize] at (label_for_y){$y$};

%An angle at P with measure x is drawn. The angle is marked with "|".
\draw[draw=blue] let \p1=($(R)-(P)$), \n1={atan(\y1/\x1)} in ($(P)!0.5cm!(O)$) arc (-30:\n1:0.5);
\draw[draw=blue] let \p1=($(R)-(P)$), \n1={atan(\y1/\x1)} in ($($(P) +({0.5*(\n1-30)}:0.5)$)!-3pt!(P)$) -- ($($(P) +({0.5*(\n1-30)}:0.5)$)!3pt!(P)$);

%An angle at Q with measure x is drawn. The angle is marked with "|".
\draw[draw=blue] 
  let 
  \p1=($(Q)-(R)$), 
  \n1={atan(\y1/\x1)}, 
  \p2=($(Q)-(P)$), 
  \n2={atan(\y2/\x2)} 
  in 
  ($(Q)!0.5cm!(R)$) arc (\n1:{\n2 - 180}:0.5);

%\draw[draw=blue,fill] 
%  let \p1=($(Q)-(R)$), 
%  \n1={atan(\y1/\x1)}, 
%  \p2=($(Q)-(P)$), 
%  \n2={atan(\y2/\x2)} 
%  in
%  ($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!-3pt!(Q)$) -- 
%  ($($(Q) +({0.5*(\n1+\n2+180)}:-0.5)$)!3pt!(Q)$);

\draw[draw=green,fill] 
  let 
  \p1=($(Q)-(R)$), 
  \n1={atan(\y1/\x1)}, 
  \p2=($(Q)-(P)$), 
  \n2={atan(\y2/\x2)} 
  in
  ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5cm-5pt})$) -- 
  ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5cm+5pt})$);

\end{tikzpicture}

\end{document}

enter image description here

|improve this answer|||||

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.