% Euler's Line. % This displays the construction of a centroid, circumcenter, and % orthocenter, and connects them to form Euler's line. % Greg Heartsfield % August 31, 2008 prologues:=3; beginfig(1); u := 4cm; % Vertices pair a, b, c; a := (-0.5u, 0u); b := (1u,1u); c := (1.4u,-0.3u); % Draw triangle draw a--b--c--cycle; dotlabel.llft("a", a); dotlabel.urt("b", b); dotlabel.lrt("c", c); %%% Centroid %%% draw a--(1/2[b,c]) dashed evenly; draw b--(1/2[a,c]) dashed evenly; draw c--(1/2[a,b]) dashed evenly; path g, h; g = a .. (1/2[b,c]); h = b .. (1/2[a,c]); pair centroid; centroid = (g intersectionpoint h); %%% Orthorcenter %%% pair oca, ocb, occ, dma, dmb, dmc; oca = whatever[b,c]; dma = unitvector direction 0 of (c--b) rotated 90; oca = whatever[a,a-dma]; draw a--oca dashed dashpattern (on 1bp off 1bp); draw ((-1,0)--(-1,-1)--(0,-1)) zscaled (6pt*unitvector(oca-a)) shifted (oca); ocb = whatever[a,c]; dmb = unitvector direction 0 of (c--a) rotated 90; ocb = whatever[b,b-dmb]; draw b--ocb dashed dashpattern (on 1bp off 1bp); draw ((1,0)--(1,1)--(0,1)) zscaled (6pt*unitvector(ocb-a)) shifted (ocb); occ = whatever[a,b]; dmc = unitvector direction 0 of (b--a) rotated 90; occ = whatever[c,c-dmc]; draw c--occ dashed dashpattern (on 1bp off 1bp); draw ((-1,0)--(-1,-1)--(0,-1)) zscaled (6pt*unitvector(occ-a)) shifted (occ); pair orthoc; orthoc = whatever[a,oca]; orthoc = whatever[b,ocb]; %%% Circumcenter %%% draw a..b..c..cycle; % constraints for the circumcenter pair cc; cc = (a + c)/2 + whatever*(c - a) rotated 90; cc = (b + c)/2 + whatever*(c - b) rotated 90; % Draw a line from the circumcenter perpendicular to a side. def draw_cc_line(expr beginp, endp) = pair ccx, ccdmx; ccdmx = unitvector direction 0 of (beginp--endp) rotated 90; ccx = whatever[beginp,endp] = whatever[cc,cc-ccdmx]; draw cc--ccx; enddef; draw_cc_line(a,c); draw_cc_line(b,c); draw_cc_line(a,b); %%% Euler's Line %%% pickup pencircle scaled 3pt; drawdot centroid; drawdot cc; drawdot orthoc; % connect the dots pickup pencircle scaled 0.75pt; draw centroid--cc--orthoc; endfig; end.