# Create angle bisectors in TikZ

Suppose we have a triangle ABC of given coordinates. Let AD be its altitude. How can I draw the bisector of angle BCD? I'd like to avoid manual calculation of coordinates. I'd rather not use TKZ-Euclide due to its lack of English documentation.

My minimal working example:

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,intersections}
\begin{tikzpicture}

\coordinate[label=below left:$C$](C) at (-2,0);
\coordinate[label=below right:$A$](A) at (8,0);
\coordinate[label=above left:$B$] (B) at (0,7);
\coordinate[label=above right:$D$](D) at ($(A)!(C)!(B)$);
\draw (A) -- (B) -- (C) -- cycle;
\draw (C) -- (D);

\end{tikzpicture}


\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{xparse}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,intersections}

\usetikzlibrary{through}

\NewDocumentCommand{\bissectrice}{%
O{}     % drawing options
mmm     % bissector of mmm
m       % intersection point between base and bissector
O{1}O{1}% extended drawing of the bissector
}{%
\path[name path=Bis#2#3#4] let
\p1 = ($(#2) - (#3)$),
\p2 = ($(#4) - (#3)$),
\n1 = {veclen(\x1,\y1)} ,
\n2 = {veclen(\x2,\y2)} ,
\n3 = {max(\n1,\n2)},
\p1 = ($(#3)!\n3!(#2)$),
\p2 = ($(#3)!\n3!(#4)$),
\p3 = ($(\p1) + (\p2) - (#3)$)
in
(#3) -- (\p3) ;

\path[name path = foo] (#2)--(#4) ;

\path[name intersections={of=foo and Bis#2#3#4, by=#5}] ;

\path[#1] ($(#3)!#6!(#5)$) -- ($(#5)!#7!(#3)$) ;
}

\begin{document}
\begin{tikzpicture}

\coordinate[label=below left:$C$](C) at (-2,0);
\coordinate[label=below right:$A$](A) at (8,0);
\coordinate[label=above left:$B$] (B) at (0,7);
\coordinate[label=above right:$D$](D) at ($(A)!(C)!(B)$);
\draw (A) -- (B) -- (C) -- cycle;
\draw (C) -- (D);

\bissectrice[draw,blue]  {B}{C}{D}{R}[1.1]
\bissectrice[draw,dashed]{D}{B}{C}{S}
\bissectrice[draw,dashed]{C}{D}{B}{T}

\path[name intersections={of=BisBCD and BisDBC, by=O}] ;

\node [draw=red] at (O) [circle through={($(C)!(O)!(B)$)}] {};

\end{tikzpicture}
\end{document}


Old version

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,intersections}

\newcommand{\bissectrice}[6][]{%
\path[#1] let
\p1 = ($(#3)!1cm!(#2)$),
\p2 = ($(#3)!1cm!(#4)$),
\p3 = ($(\p1) + (\p2) - (#3)$)
in
($(#3)!#6!(\p3)$) -- ($(\p3)!#5!(#3)$) ;
}

\begin{document}
\begin{tikzpicture}

\coordinate[label=below left:$C$](C) at (-2,0);
\coordinate[label=below right:$A$](A) at (8,0);
\coordinate[label=above left:$B$] (B) at (0,7);
\coordinate[label=above right:$D$](D) at ($(A)!(C)!(B)$);
\draw (A) -- (B) -- (C) -- cycle;
\draw (C) -- (D);

\bissectrice[draw,red]{B}{C}{D}{1.5}{4}

\end{tikzpicture}
\end{document}

• Is anything wrong with the old version? – marmistrz Mar 17 '15 at 17:43
• Nothing, but the new one as more feature: calculation of the intersection point between the bissector and the opposite side , automatic name of the bissector. – Tarass Mar 17 '15 at 21:14
• @Tarass Why the following does not give me the angle bisector:  \coordinate (O) at (0,0); \coordinate (A) at ($(O)+(195:4)$); \coordinate (B) at ($(O)+(95:4)$); \coordinate (C) at ($(O)+(-5:4)$); \coordinate (D) at ($(O)+(-85:4)$); \bissectrice[draw]{A}{B}{C}{I}[2] And I get No shape named intersection-1 is known. – blackened Feb 9 at 16:49
• In this really case, the there some bad rounding in calculations that prevent the intersection of the base and the bissector. I took off the /2 in the length calculation and in works fine. I edited my answer. – Tarass Feb 9 at 17:35

Here's how you would do this with tkz-euclide: \tkzDrawBisector(B,C,D)

\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-2,xmax=8,ymin=0,ymax=7]
\tkzClip[space=1]

\tkzDefPoint(8,0){A}
\tkzDefPoint(0,7){B}
\tkzDefPoint(-2,0){C}

\tkzDefPointBy[projection=onto A--B](C)
\tkzGetPoint{D}

\tkzDrawPolygon(A,B,C)
\tkzDrawSegment(C,D)
\tkzDrawBisector(B,C,D)

\tkzLabelPoints(A)
\tkzLabelPoints[above right](B,D)
\tkzLabelPoints[below left](C)
\end{tikzpicture}
\end{document}


One tikz solution

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,intersections}

\begin{document}
\begin{tikzpicture}

\coordinate[label=below left:$C$](C) at (-2,0);
\coordinate[label=below right:$A$](A) at (8,0);
\coordinate[label=above left:$B$] (B) at (0,7);
\coordinate[label=above right:$D$](D) at ($(A)!(C)!(B)$);

%  first name the path
\draw[name path=t1] (A) -- (B) -- (C) -- cycle;
\draw[name path=CD] (C) -- (D);

% draw circle
\path[name path=c1] (B) circle (2);
% name intersection
\path [name intersections={of = c1 and t1, by={a,b}}];
% draw line beetwen intersections
\path (a)--(b);
% draw the bissector
\path[name path=bissec] (B) -- ($(a)!0.5!(b)$) coordinate[pos=3](ff) --(ff);
\path [name intersections={of = CD and bissec, by=c}];

\draw[thick,red] (B) --(c);

\end{tikzpicture}
\end{document}


• You have drawn the bissector of CBD instead of BCD. – Tarass Mar 15 '15 at 17:13

With MetaPost, inside a LuaLaTeX program.

The draw_mark, mark_angle and mark_right_angle macros, which make the coding much longer than it could have been, are not mandatory at all to produce the figure, but I think that this bisector figure is made clearer by marking the angles accordingly. These macros come (slightly simplified) from André Heck's wonderful tutorial in MetaPost. André Heck himself borrowed them from the MetaPost manual, and improved them at the same time.

\documentclass[12pt, border=2bp]{standalone}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}

vardef draw_mark(expr p, mark_size) =
save t, dm;
t = arctime .5arclength(p) of p;
pair dm; dm = mark_size*unitvector(direction t of p rotated 90);
draw (-.5dm -- .5dm) shifted (point t of p);
enddef;

vardef mark_angle (expr endofa, common, endofb, mark_size) =
save p, tn; tn := turningnumber(common -- endofa -- endofb -- cycle);
path p; p = (unitvector(endofa-common){(endofa-common) rotated (tn*90)}
.. unitvector(endofb-common)) scaled mark_size shifted common;
draw p; draw_mark(p, 5bp);
enddef ;

vardef mark_right_angle (expr endofa, common, endofb, mark_size) =
save tn; tn := turningnumber(common -- endofa -- endofb -- cycle);
((1, 0) -- (1, 1) -- (0, 1))
zscaled (mark_size*unitvector((1+tn)*endofa + (1-tn)*endofb - 2*common))
shifted common
enddef ;

beginfig(1);
u := cm; pair A, B, C, D, E;
A = (8u, 0); B = (0, 7u); C = (-2u, 0);
D = whatever[A, B] = whatever[C, C + (B-A) rotated 90];
draw A--B--C--cycle; draw C--D;
draw mark_right_angle(C, D, B, 2mm);
E = C + whatever*(unitvector(D-C)+unitvector(B-C)) = whatever[A,B];
draw C--E withcolor red;
mark_angle (D, C, E, 1.25cm); mark_angle (B, C, E, 1.25cm);
label.bot("$A$", A); label.lft("$B$", B); label.bot("$C$", C); label.urt("$D$", D);
endfig;

\end{mplibcode}
\end{document}


• E = C + whatever*(unitvector(D-C)+unitvector(B-C)) = whatever[A,B]; is a little cleaner... – Thruston Mar 15 '15 at 21:04
• @Thruston Indeed. Adopted. – Franck Pastor Mar 15 '15 at 21:44

An inline Asymptote version:

% bisect.tex
%
\documentclass{article}
\usepackage[inline]{asymptote}
\usepackage{lmodern}
\begin{document}
\begin{figure}
\centering
\begin{asy}
size(7cm);
pen linePen=deepblue+1.2bp, bisectPen=orange+0.8bp;
pair A,B,C,D,E; real CAB,ACD,BCD;
C=(-2,0); A=(8,0); B=(0,7);
CAB=degrees(C-A)-degrees(B-A);
ACD=90-CAB;
D=extension(A,B,C,rotate(ACD,C)*A);
BCD=degrees(B-C)-degrees(D-C);
E=extension(A,B,C,rotate(BCD/2,C)*D);
draw(C--A--B--C--D,linePen);
draw(C--E,bisectPen);
pair[] node={A,B,C,D,E}; string nodename="ABCDE";
pair[] nodepos={
plain.E, plain.N, plain.W, plain.NE, plain.NE,
};
dot(node,UnFill);
for(int i=0;i<node.length;++i)label("$"+substr(nodename,i,1)+"$",node[i],nodepos[i]);
label("$CD\perp AB,\ \angle BCE=\angle ECD$",(A+C)/2,plain.S);
\end{asy}
\caption{Angle bisector with \texttt{Asymptote}}
\end{figure}
\end{document}
%
% To get bisect.pdf, process:
%
% pdflatex bisect.tex
% asy bisect-*.asy
% pdflatex bisect.tex

• Following Thruston's comment on my own answer with MetaPost above, to find D and E I would suggest D=extension(A, B, C, C+rotate(90)*(B-A)); and E=extension(A, B, C, C+unit(B-C)+unit(D-C));. The variables CAB, ACD and BCD become useless then. – Franck Pastor Mar 16 '15 at 12:54
• @fpast: The reasons for the variables CAB, ACD and BCD are: 1) clarity; 2) one might like to know the values of the angles. – g.kov Mar 16 '15 at 13:18