A triangle is drawn via the following code. (In the display, only two of the vertices are labeled. In the code, the vertices are labeled A, B, and C.) I extend sides AC and BC. I want to draw a ray that bisects the (acute) angle made by these extended sides.

I have specified \coordinate (A) at (0,0); and \coordinate (C) at (290:3.25);; so, I know the extension of side AC is at an angle of 70 degrees below the horizontal line through C. The angle that the extension of side BC is above the horizontal line through C would have to be expressed in terms of an arc tangent of a messy expression! Can this ray be drawn using the calc package?



%A is the vertex of an angle of 55 degrees; the sides of this angle are AB
%and AC. $AB = 22$ and $AC = 13$.
\coordinate (A) at (0,0);
\node (vertex_A) at ($(A) + (82.5:7.5pt)$){$A$};
\coordinate (B) at (235:5.5);
\node (vertex_B) at ($(B) + (225:7.5pt)$){$B$};
\coordinate (C) at (290:3.25);
\draw[name path=AB] (A) -- (B);
\draw[name path=AC] (A) -- (C);
\draw[name path=BC] (B) -- (C);

%These commands label the lengths of AB and of AC.
\coordinate (AB_midpoint) at ($(A)!0.5!(B)$);
\coordinate (AC_midpoint) at ($(A)!0.5!(C)$);

%These commands draw the altitude of the triangle from C. The foot of the altitude is
%labeled P.
\coordinate (P) at ($(A)!(C)!(B)$);
\draw[dashed] (C) -- (P);
\coordinate (PC_midpoint) at ($(P)!0.5!(C)$);

%The following commands make the right-angle mark.
\coordinate (U) at ($(P)!4mm!-45:(A)$);
\draw (U) -- ($(P)!(U)!(A)$);
\draw (U) -- ($(P)!(U)!(C)$);

\coordinate (S) at ($(B)!1.75!(C)$);
\coordinate (T) at ($(A)!2!(C)$);

\draw[-latex,loosely dashed,green] (C) -- (S);
\draw[-latex,loosely dashed,green] (C) -- (T);



4 Answers 4


You can use calc to calculate the angle:

\draw let \p1=($(S)-(C)$), \p2=($(T)-(C)$), \n0={.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)} in
   (C) -- +(\n0:2);

You can construct the bisect:

\draw (C) -- ($($(C)!2cm!(S)$)!.5!($(C)!2cm!(T)$)$);

This uses layered calculation which might create issued, so you could just do the calculations beforehand with

… let \p1=($(C)!2cm!(S)$), \p2=($(C)!2cm!(T)$) in (C) -- ($(\p1)!.5!(\p2)$) …

However if you define S and T in equal distance from C, for example

\path ($(C)!-2cm!(B)$) coordinate (S)
      ($(C)!-2cm!(A)$) coordinate (T);

you could just do

\draw (C) -- ($(S)!.5!(T)$);

You could (should in my opinion) wrap this solution in an insert path, say something like

  calc angle between/.style args={#1--#2--#3}{%
    insert path={let \p{@aux1}=($(#1)-(#2)$), \p{@aux2}=($(#3)-(#2)$),
      \n{angle}={.5*atan2(\y{@aux1},\x{@aux1})+.5*atan2(\y{@aux2},\x{@aux2})} in}}}

and then you can just do

\draw[calc angle between=S--C--T] (C) -- +(\n{angle}:2);

I also provide a PGFmath-powered solution which provides you with a function anglebisect(<p1>, <p2>, <p3>, <p4>) that calculates the directional angle for the lines (<p1>) -- (<p2>) and (<p3>) -- (<p4>) (in your case <p1> equals <p3>). Unfortunately, PGFmath needs " wrapped around such arguments as it should not evaluate them.


    \edef\pgf@marshall{\expandafter\noexpand\csname pgfmathatan2@\endcsname
  calc angle between/.style args={#1--#2--#3}{%
    insert path={let \p{@aux1}=($(#1)-(#2)$), \p{@aux2}=($(#3)-(#2)$),
      \n{angle}={.5*atan2(\y{@aux1},\x{@aux1})+.5*atan2(\y{@aux2},\x{@aux2})} in}}}
\path[every label/.append style={circle,inner sep=1pt}]
      (0,0)      coordinate[label=$A$] (A)
    + (235:5.5)  coordinate[label=below left:$B$] (B)
    + (290:3.25) coordinate (C)
    ($(A)!.5!(B)$)  coordinate (AB_midpoint)
    ($(A)!.5!(C)$)  coordinate (AC_midpoint)
    ($(A)!(C)!(B)$) coordinate (P)
    ($(P)!.5!(C)$)  coordinate (PC_midpoint);
\draw (A) -- (B) -- (C) -- cycle;
% or: \draw plot coordinates {(A)(B)(C)} -- cycle;

\draw[dashed] (C) -- (P);
\draw coordinate (U) at ($(P)!4mm!-45:(A)$)
  ($(P)!(U)!(A)$) -- (U) -- ($(P)!(U)!(C)$);

\draw[Latex-Latex,loosely dashed,green]
  ($(B)!1.75!(C)$) coordinate (S)
  -- (C) --
  ($(A)!2!(C)$)    coordinate (T);

\draw[line width=.2cm] let \p1=($(S)-(C)$), \p2=($(T)-(C)$),
                 \n0={.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)} in
  (C) -- +(\n0:2);

\draw[line width=.15cm,red]    (C) -- ($($(C)!2cm!(S)$)!.5!($(C)!2cm!(T)$)$);
\draw[line width=.1cm,white] (C) -- +({anglebisect("C","S","C","T")}:1);

\draw[dashed,thick, calc angle between=S--C--T] (C) -- +(\n{angle}:2);

\path ($(C)!-2cm!(B)$) coordinate (S)
      ($(C)!-2cm!(A)$) coordinate (T);
\draw[thick,dashed,blue!50,dash phase=3pt] (C) -- ($(S)!.5!(T)$);


enter image description here

  • I appreciate the different options that you offered!
    – user74973
    Jun 15, 2015 at 21:45
  • I should have said that S and T are arbitrary points on the two rays from C, in which case, your lsecond option is the simplest code to use.
    – user74973
    Jun 15, 2015 at 21:45
  • I would like to understand your first option: \draw let \p1=($(S)-(C)$), \p2=($(T)-(C)$), \n0={.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)} in (C) -- +(\n0:2); What is ``\draw let? I looked for this in the pgf` manual. How does the calc package interpret ($(S)-(C)$)? What is \p1? Is that the name for ($(S)-(C)$? What is x1 and \y1 in {.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)}? How does TikZ interpret this last command?
    – user74973
    Jun 15, 2015 at 21:45
  • 1
    @user74973 For let, take a look at section 14.15 "The Let Operation". \p1=($(S)-(C)$) calculates the vector from C to S and saves it so that you can acess it again with \p1 (which will expand to \x1,\y1). The \x and \y macros holds the coordinates of the \p point in pt which I use later to calculate the angles. So atan2(\y1,\x1) calculates the angle from the vector from C to S. \n can be used in the let … in part to calculate something. See section 13.5 "Coordinate Calculations" in the manual. Jun 15, 2015 at 22:15

The angle between the horizontal line to BC can be calculated via \pgfmathanglebetweenpoints:

\pgfmathsetmacro\RayAngle{(-70 + \AngleTmp)/2}


  • I just looked in a pgfplots manual for \pgfmathanglebetweenpoints. It wasn't mentioned. I am not familiar with this command or any of the other commands that you used - \pgfpointanchor, \pgfmathresult, or \pgfmathsetmacro. Your code gives me what I want, though. And I don't have to load any other packages.
    – user74973
    Jun 15, 2015 at 18:14
  • @user74973 pgfplots is a quite different package, neither loaded or used here. \pgfmathanglebetweenpoints and the other commands are explained in the manual for TikZ/pgf. Jun 15, 2015 at 18:22

If you're open to a new package, you can use tkz-euclide then add this to your preamble:


Then use the following commands:

\tkzDrawSegment[red, dotted](C,a)

Here's the output:

figure 1

  • Yep. This is the display that I wanted. I don't want to use tkz-euclide, though.
    – user74973
    Jun 15, 2015 at 18:16
  • @user74973 It's doable with Tikz only. Only Tikz will require some calculations and more code, though.
    – Alenanno
    Jun 15, 2015 at 18:19
  • As I am trying to get familiar with TikZ, I can tolerate more tedious coding. I should have specified this in my post. (I did ask whether this angle bisector could be drawn using the calc package.) Take a look at the code provided by Qrrbrbirlbel.
    – user74973
    Jun 15, 2015 at 22:04

Here is simplified version of your code. The bisector is drawn using two points (S) and (T) positioned at the same distance from (C). Only the calc library is used.


    % draw the triangle
    \path (0,0) coordinate (A) node[above] {$A$}
        (235:5.5) coordinate (B) node[below left]{$B$}
        (290:3.25) coordinate (C);
    \draw (A) -- (B) -- (C) -- cycle;

    % draw dashed height
    \draw[dashed] (C) -- ($(A)!(C)!(B)$) coordinate (P);

    %The following commands make the right-angle mark.
    \draw ($(P)!4mm!(A)$) -- ([turn]90:4mm) -- ([turn]-90:4mm);

    % draw the opposit angle and the bisector in red
    \draw[-latex,loosely dashed,green] (C) -- ($(C)!-2cm!(B)$) coordinate (S) -- ([turn]0:15mm);
    \draw[-latex,loosely dashed,green] (C) -- ($(C)!-2cm!(A)$) coordinate (T) -- ([turn]0:5mm);
    \draw[thick, red] (C) -- ($(S)!.5!(T)$) -- ([turn]0:15mm);

enter image description here

Note: The first [turn] in the right-angle mark is a mystery for me, but it works.

  • Please tell me what [turn] instructs TikZ to do. Where is a discussion of [turn] in the manual?
    – user74973
    Jun 21, 2015 at 14:34
  • 1
    From the manual (/tikz/turn) : The effect of this key is to locally shift the coordinate system so that the last point reached is at the origin and the coordinate system is “turned” so that the x-axis points in the direction of a tangent entering the last point.
    – Kpym
    Jun 21, 2015 at 14:37

You must log in to answer this question.

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