Triangle Centers

Adam Rumpf, 2/2/2016

Introduction

This demonstration defines a Manipulate environment for displaying several different classical triangle centers as well as some auxiliary lines. The vertices of the triangle can be clicked and dragged to change the shape of the triangle, and the tick boxes can be used to choose what to show or hide. The following triangle centers are included:

Orthocenter: Intersection of the three altitudes.

Circumcenter: Center of the circle circumscribed about the triangle.

Centroid: Intersection of the three lines connecting each vertex to its opposite side’s midpoint.

Incenter: Center of the circle inscribed inside the triangle.

The construction lines and inscribed/circumscribed circles can be toggled on or off, as can the Euler line, along which the orthocenter, circumcenter, and centroid (but not necessarily the incenter) always lie. Note that all four centers coincide for an equilateral triangle.

Code

Demonstration

Manipulate[Module[{mab,mbc,mca,orthmalta,orthmaltb,orthmaltc,eqab,eqbc,eqca,ortheqalta,ortheqaltb,ortheqaltc,orthfoota={0,0},orthfootb={0,0},orthfootc={0,0},orthocenter={0,0},midab,midbc,midca,circnormasq,circnormbsq,circnormcsq,circumcenter,circsx,circsy,circad,circbd,circr,centroid,inmbia,inmbib,inmbic,ineqbia,ineqbib,ineqbic,inintab={0,0},inintbc={0,0},inintca={0,0},incenter={0,0},inr,indsqab,indsqbc,indsqca},
(* Orthocenter *)
mab=If[a[[1]]≠b[[1]],((b[[2]]-a[[2]])/(b[[1]]-a[[1]])),Infinity];
mbc=If[b[[1]]≠c[[1]],((c[[2]]-b[[2]])/(c[[1]]-b[[1]])),Infinity];
mca=If[a[[1]]≠c[[1]],((a[[2]]-c[[2]])/(a[[1]]-c[[1]])),Infinity];
orthmalta=If[mbc≠0,-(1/mbc),Infinity];
orthmaltb=If[mca≠0,-(1/mca),Infinity];
orthmaltc=If[mab≠0,-(1/mab),Infinity];
eqab=mab(#-a[[1]])+a[[2]]&;
eqbc=mbc(#-b[[1]])+b[[2]]&;
eqca=mca(#-c[[1]])+c[[2]]&;
ortheqalta=orthmalta(#-a[[1]])+a[[2]]&;
ortheqaltb=orthmaltb(#-b[[1]])+b[[2]]&;
ortheqaltc=orthmaltc(#-c[[1]])+c[[2]]&;
orthfoota[[1]]=x/.Solve[ortheqalta[x]==eqbc[x],x][[1]];
orthfoota[[2]]=ortheqalta[orthfoota[[1]]];
orthfootb[[1]]=x/.Solve[ortheqaltb[x]==eqca[x],x][[1]];
orthfootb[[2]]=ortheqaltb[orthfootb[[1]]];
orthfootc[[1]]=x/.Solve[ortheqaltc[x]==eqab[x],x][[1]];
orthfootc[[2]]=ortheqaltc[orthfootc[[1]]];
orthocenter[[1]]=x/.Solve[ortheqalta[x]==ortheqaltb[x],x][[1]];
orthocenter[[2]]=ortheqalta[orthocenter[[1]]];
(* Circumcenter *)
midab=Mean[{a,b}];
midbc=Mean[{b,c}];
midca=Mean[{c,a}];
circnormasq=((a[[1]])^2)+((a[[2]])^2);
circnormbsq=((b[[1]])^2)+((b[[2]])^2);
circnormcsq=((c[[1]])^2)+((c[[2]])^2);
circsx=(1/2)Det[{{circnormasq,a[[2]],1},{circnormbsq,b[[2]],1},{circnormcsq,c[[2]],1}}];
circsy=(1/2)Det[{{a[[1]],circnormasq,1},{b[[1]],circnormbsq,1},{c[[1]],circnormcsq,1}}];
circad=Det[{{a[[1]],a[[2]],1},{b[[1]],b[[2]],1},{c[[1]],c[[2]],1}}];
circbd=Det[{{a[[1]],a[[2]],circnormasq},{b[[1]],b[[2]],circnormbsq},{c[[1]],c[[2]],circnormcsq}}];
circumcenter={circsx,circsy}/circad;
circr=(Sqrt[(circbd/circad)+(((circsx^2)+(circsy^2))/(circad^2))]);
(* Centroid *)
centroid=Mean[{a,b,c}];
(* Incenter *)
inmbia=Tan[((ArcTan[mab]+ArcTan[mca])/2)];
inmbib=Tan[((ArcTan[mab]+ArcTan[mbc])/2)];
inmbic=Tan[((ArcTan[mbc]+ArcTan[mca])/2)];
ineqbia=inmbia(#-a[[1]])+a[[2]]&;
ineqbib=inmbib(#-b[[1]])+b[[2]]&;
ineqbic=inmbic(#-c[[1]])+c[[2]]&;
inintbc[[1]]=x/.Solve[eqbc[x]==ineqbia[x],x][[1]];
inintbc[[2]]=eqbc[inintbc[[1]]];
If[(inintbc[[1]]<b[[1]]&&inintbc[[1]]<c[[1]])||(inintbc[[1]]>b[[1]]&&inintbc[[1]]>c[[1]])||(inintbc[[2]]<b[[2]]&&inintbc[[2]]<c[[2]])||(inintbc[[2]]>b[[2]]&&inintbc[[2]]>c[[2]]),
inmbia=If[inmbia≠0,-(1/inmbia),Infinity];
inintbc[[1]]=x/.Solve[eqbc[x]==ineqbia[x],x][[1]];
inintbc[[2]]=eqbc[inintbc[[1]]];
];
inintca[[1]]=x/.Solve[eqca[x]==ineqbib[x],x][[1]];
inintca[[2]]=eqca[inintca[[1]]];
If[(inintca[[1]]<a[[1]]&&inintca[[1]]<c[[1]])||(inintca[[1]]>a[[1]]&&inintca[[1]]>c[[1]])||(inintca[[2]]<a[[2]]&&inintca[[2]]<c[[2]])||(inintca[[2]]>a[[2]]&&inintca[[2]]>c[[2]]),
inmbib=If[inmbib≠0,-(1/inmbib),Infinity];
inintca[[1]]=x/.Solve[eqca[x]==ineqbib[x],x][[1]];
inintca[[2]]=eqca[inintca[[1]]];
];
inintab[[1]]=x/.Solve[eqab[x]==ineqbic[x],x][[1]];
inintab[[2]]=eqab[inintab[[1]]];
If[(inintab[[1]]<a[[1]]&&inintab[[1]]<b[[1]])||(inintab[[1]]>a[[1]]&&inintab[[1]]>b[[1]])||(inintab[[2]]<a[[2]]&&inintab[[2]]<b[[2]])||(inintab[[2]]>a[[2]]&&inintab[[2]]>b[[2]]),
inmbic=If[inmbic≠0,-(1/inmbic),Infinity];
inintab[[1]]=x/.Solve[eqab[x]==ineqbic[x],x][[1]];
inintab[[2]]=eqab[inintab[[1]]];
];
incenter[[1]]=x/.Solve[ineqbia[x]==ineqbib[x],x][[1]];
incenter[[2]]=ineqbia[incenter[[1]]];
indsqab=(((inintab[[1]]-incenter[[1]]))^2)+(((inintab[[2]]-incenter[[2]]))^2);
indsqbc=(((inintbc[[1]]-incenter[[1]]))^2)+(((inintbc[[2]]-incenter[[2]]))^2);
indsqca=(((inintca[[1]]-incenter[[1]]))^2)+(((inintca[[2]]-incenter[[2]]))^2);
inr=(Sqrt[Min[indsqab,indsqbc,indsqca]]);
(* Graphics *)
Graphics[Join[{Black,Line[{a,b,c,a}]},If[eulershow==True&&orthocenter≠circumcenter,{InfiniteLine[{orthocenter,circumcenter}]},{}],{PointSize[Large],Blue,Point[orthocenter]},If[orthshow==True,{InfiniteLine[{a,orthfoota}],Point[orthfoota],InfiniteLine[{b,orthfootb}],Point[orthfootb],InfiniteLine[{c,orthfootc}],Point[orthfootc]},{}],{Green,Point[circumcenter]},If[circshow==True,{InfiniteLine[{midbc,circumcenter}],Point[midbc],InfiniteLine[{midca,circumcenter}],Point[midca],InfiniteLine[{midab,circumcenter}],Point[midab]},{}],If[circcircleshow==True,{Circle[circumcenter,circr]},{}],{Red,Point[centroid]},If[centshow==True,{InfiniteLine[{a,midbc}],Point[midbc],InfiniteLine[{b,midca}],Point[midca],InfiniteLine[{c,midab}],Point[midab]},{}],{Orange,Point[incenter]},If[inshow==True,{InfiniteLine[{a,inintbc}],Point[inintbc],InfiniteLine[{b,inintca}],Point[inintca],InfiniteLine[{c,inintab}],Point[inintab]},{}],If[insccircleshow==True,{Circle[incenter,inr]},{}]],PlotRange->1]
],{{a,{-0.2,0.7}},Locator},{{b,{0.7,-0.1}},Locator},{{c,{-0.5,-0.3}},Locator},
{{eulershow,True,"Show Euler Line"},{True->"On",False->"Off"}},{{orthshow,False,"Show Orthocenter Construction Lines"},{True->"On",False->"Off"}},{{circshow,False,"Show Circumcenter Construction Lines"},{True->"On",False->"Off"}},
{{centshow,False,"Show Centroid Construction Lines"},{True->"On",False->"Off"}},
{{inshow,False,"Show Incenter Construction Lines"},{True->"On",False->"Off"}},{{circcircleshow,False,"Show Circumscribed Circle"},{True->"On",False->"Off"}},{{insccircleshow,False,"Show Inscribed Circle"},{True->"On",False->"Off"}},ControlType->Checkbox]