# Triangle. Changing vertices. Draw the height of the triangle

1) I'm a drawing triangles in latex, but I want the vertices A and B to be horizontal. In the code below vertices A and C are horizontal. I have problem changing the code.

2) I want to add a stripping/dashed line from C to a point D on the segment AB, representing the height of the triangle. Please help. This is my code:

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}

\tikzset{
myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}

\begin{document}
\begin{tikzpicture}

% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:B] (b);

\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (b)--++(-45:8);
\path[name intersections={of = ac and bc, by=c}];
\node[anchor=west] at (c) {C};

\draw[use as bounding box] (a)--(b)--(c)--cycle;

% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(b)$);

%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (b) -- (c);
%\path[name intersections={of = incls and altbc, by=t}];

%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};

% Angles
\tkzFindAngle(a,b,c)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(c,a,b)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(b,c,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}

\tkzMarkAngle[myangle](a,b,c)
\tkzLabelAngle[pos=.4](a,b,c){\tiny $\angleABC^\circ$}

\tkzMarkAngle[myangle](c,a,b)
\tkzLabelAngle[pos=0.5](c,a,b){\tiny $\angleCAB^\circ$}

\tkzMarkAngle[myangle](b,c,a)
\tkzLabelAngle[pos=0.45](b,c,a){\tiny $\angleBCA^\circ$}

%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}

%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}


in comment you actually ask new question ... if i understood you correctly, you ask something like this:

if i'm correct, than be so kind and ask new question, that i will be able provide code for above image there and in the first place other members on the site have possibilities to help you.

code is now available here.

pure tikzsolution:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, intersections, positioning, quotes}
\usepackage{siunitx}

\begin{document}
\begin{tikzpicture}[
draw=green!50!black, fill=green!20!white}
]
% Drawing the triangle and the coordinates
\coordinate[label=left:A]  (a);
\coordinate[label=right:B,right=8.5 of a] (b);
\path[name path=ac] (a) -- ++ ( 60:6.5);
\path[name path=bc] (b) -- ++ (135:8);
\path[name intersections={of = ac and bc, by=c}] node[label=C] at (c)  {};;
\draw (a)--(c)--(b)--cycle;
% Angles
\pic [myangle, "\ang{60}"] {angle = b--a--c};
\pic [myangle, "\ang{45}"] {angle = c--b--a};
\pic [myangle, "\ang{75}"] {angle = a--c--b};
\draw[dashed] (c) -- (c |- a) coordinate[label=below:D] (d);
\end{tikzpicture}
\end{document}


• @Eirik, if my answer solve your problem, please vote for it and even accept it (by clicking on up-pen and check mark at top left side of answer). this is way how on this site express "thank you". – Zarko Jan 19 '18 at 14:18
• Can you help me extend this triangle to a quadrilateral such that angle BCE = 90degrees point E has the same y-coordinate as point A? – Eirik Jan 23 '18 at 11:29
• but this is geometry question, isn't it? :-) at list is new one. as such in comment is not visible to others who will know how to do this and will be willing to answer ... apart this, i don't understand you, where should be E. on the same place as D? please clarify this in (new) question. – Zarko Jan 23 '18 at 11:40
• The point E will be on the same line as the ray BA, having the same y-coordinate as point A and B, to the left of A. Angle BCE = 90. That means Angle ACE =15grader. That means you need to extend the the horisontal line and the line vil intersect with the angle constructed. – Eirik Jan 23 '18 at 12:04

Just for comparison, here is a version in Metapost wrapped up in luamplib, so you need to compile it with lualatex or workout how to adapt it for plain MP, or GMP + pdflatex.

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef mark_angle(expr a, b, c, s, tint) =
save arc; path arc;
arc = fullcircle scaled 2s rotated angle (c-b) shifted b cutafter (b--a);
fill b--arc--cycle withcolor 7/8[tint,white];
draw arc;
label("$" & decimal floor(0.5 + (angle (a-b) - angle (c-b)) mod 360) & "^\circ$",
b shifted ((s+9) * unitvector(point arctime 1/2 arclength arc of arc of arc - b)));
enddef;

beginfig(1);
pair A, B, C, D;
A = origin;
B = 300 right; % rotated 15; % <- try this just to test generality
C-A = whatever * (A-B) rotated 60;
C-B = whatever * (A-B) rotated -45;
C-D = whatever * (A-B) rotated 90;
D = whatever[A,B];

mark_angle(A,B,C,16,blue);
mark_angle(B,C,A,16,red);
mark_angle(C,A,B,16,blue);

draw A--B--C--cycle;
draw C--D dashed evenly withcolor 1/2 white;

label.rt(decimal (abs(C-D)/abs(A-B)) , 1/2[C,D]);

dotlabel.llft("A", A);
dotlabel.lrt ("B", B);
dotlabel.top ("C", C);
dotlabel.bot ("D", D);
endfig;
\end{mplibcode}
\end{document}


You mean like this?

The code:

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}

\tikzset{
myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}

\begin{document}
\begin{tikzpicture}

% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:C] (c);

\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (c)--++(-45:8);
\path[name intersections={of = ac and bc, by=b}];
\node[anchor=west] at (b) {B};

\draw[use as bounding box] (a)--(c)--(b)--cycle;

\draw[dashed] (c) |- (b);%%%% DASHED LINE

% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(c)$);

%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (c) -- (b);
%\path[name intersections={of = incls and altbc, by=t}];

%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};

% Angles
\tkzFindAngle(a,c,b)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(b,a,c)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(c,b,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}

\tkzMarkAngle[myangle](a,c,b)
\tkzLabelAngle[pos=.4](a,c,b){\tiny $\angleABC^\circ$}

\tkzMarkAngle[myangle](b,a,c)
\tkzLabelAngle[pos=0.5](b,a,c){\tiny $\angleCAB^\circ$}

\tkzMarkAngle[myangle](c,b,a)
\tkzLabelAngle[pos=0.45](c,b,a){\tiny $\angleBCA^\circ$}

%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}

%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}


I just swapped all occurrences of B by C and C by B to make the segment AB horizontal.

To draw the vertical dashed line I used a pair of perpendicular lines that start on C, go down to the same y coordinate as B and then go right to B, like this: \draw[dashed] (c) |- (b);. Since the segment AB is continuous, the horizontal part of the dashed line disappears.