Create triangle solving problems

You can try this code.

\documentclass[border=2mm,12pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[
declare function={a=5;b=7;myAngle=49;}] 
\path (0,0)  coordinate  (B)
({sqrt(a*a+b*b-2*a*b*cos(myAngle))},0)  coordinate  (C)
({(b*b - a*b*cos(myAngle))/sqrt(a*a+b*b-2*a*b*cos(myAngle))},{a*b*sin(myAngle)/sqrt(a*a+b*b-2*a*b*cos(myAngle))})  coordinate  (A)
;
\foreach \p in {A,B,C}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {A/90,B/-90,C/-90}
\path (\p)+(\g:3mm) node{$\p$};
\draw (A) -- (B) node[midway,above]{$ 7 $};
\draw (A) -- (C) node[midway,right]{$ 5 $};
\draw (B) -- (C) node[midway,below]{$ a $};
\tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
\tkzMarkAngle[size=1.3cm](B,A,C)
\end{tikzpicture}
\end{document} 

enter image description here

You can change the values a, b, myAngle.

\documentclass[border=2mm,12pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[
    declare function={a=5;b=3;myAngle=120;}] 
 \path (0,0)  coordinate  (B)
 ({sqrt(a*a+b*b-2*a*b*cos(myAngle))},0)  coordinate  (C)
 ({(b*b - a*b*cos(myAngle))/sqrt(a*a+b*b-2*a*b*cos(myAngle))},{a*b*sin(myAngle)/sqrt(a*a+b*b-2*a*b*cos(myAngle))})  coordinate  (A)
 ;
 \foreach \p in {A,B,C}
 \draw[fill=black] (\p) circle (1.5pt);
 \foreach \p/\g in {A/90,B/-90,C/-90}
 \path (\p)+(\g:3mm) node{$\p$};
 \draw (A) -- (B) node[midway,above]{$ a $};
 \draw (A) -- (C) node[midway,above]{$ b $};
 \draw (B) -- (C) node[midway,below]{$ \sqrt{a^2 + b^2 - 2ab\cos \alpha } $};
\tkzLabelAngle[pos = 0.3](B,A,C){$\alpha$}
\tkzMarkAngle[size=0.8cm](B,A,C)
\end{tikzpicture}
\end{document} 

enter image description here

With triangle knowing three sides (SSSTriangle), you can use this code. In this code, the triangle ABC, where AB=c, BC = a, AC = b.

\documentclass[12pt, border = 1mm]{standalone}
\usepackage{tkz-euclide}
\usepackage{tikz}
\begin{document}
     \begin{tikzpicture}[scale=1,declare function={a=3;b=5;c=7;}]
\coordinate (A) at (0,0);
\coordinate (B) at (c,0);
\coordinate (C) at  ({(pow(b,2) + pow(c,2) - pow(a,2))/(2*c)},{sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c)});
\foreach \p in {A,B,C}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {A/180,C/90,B/-90}
\path (\p)+(\g:3mm) node{$\p$};
%\draw (A) -- (B) -- (C) -- cycle;
\draw (A) -- (B) node[midway,below]{$  7 $};
\draw (A) -- (C) node[midway,above]{$ 5 $};
\draw (B) -- (C) node[midway,above]{$ 3 $};
\end{tikzpicture}
\end{document}

enter image description here

Triangle ABC, knowing angles A and B and side AB

\documentclass[border=2mm,12pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1,declare function={c=3;AngleA=30;AngleB=90;}]
\coordinate (A) at (0,0);
\coordinate (B) at (c,0);
\coordinate (C) at  ({c*cos (AngleA)* cosec(AngleA + AngleB) *sin(AngleB)}, {c* cosec(AngleA + AngleB)*sin (AngleA)* sin (AngleB)});
\foreach \p in {A,B,C}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {A/-90,C/90,B/-90}
\path (\p)+(\g:3mm) node{$\p$};
\draw (A) -- (B) -- (C) -- cycle;
\end{tikzpicture}
\end{document} 

enter image description here


Here an answer with tkz-euclide.

Solution for the second part of the question: How to use SSS, SAS and ASA Here my solution:

SSS, SAS and ASA in the example

\documentclass{standalone} 
\usepackage{tkz-euclide}
\makeatletter
\def\opttr{0}
\pgfkeys{/defTriangle/.cd,
SSS/.code args={a=#1 b=#2 c=#3}{%
                                  \def\a{#1}%
                                  \def\b{#2}%
                                  \def\c{#3}
                                  \def\opttr{0}},
SAS/.code args={b=#1 A=#2 c=#3}{%
                                  \def\b{#1}%
                                  \def\A{#2}%
                                  \def\c{#3}
                                  \def\opttr{1}},
ASA/.code args={A=#1 c=#2 B=#3}{%
                                  \def\A{#1}%
                                  \def\c{#2}%
                                  \def\B{#3}
                                  \def\opttr{2}}} 
\def\DefTriangle[#1]#2{% 
\begingroup 
\pgfqkeys{/defTriangle}{#1}    
 \ifcase\opttr% 
   \ThreeSide(\a,\b,\c)(#2)
   \or
   \TwoSide(\b,\A,\c)(#2)
   \or
   \OneSide(\A,\c,\B)(#2)
\fi    
\endgroup
}

\def\ThreeSide(#1,#2,#3)(#4,#5,#6){%
\begingroup 
\tkzDefPoints{0/0/#4,#3/0/#5}
\tkzInterCC[R](#4,#2 cm)(#5,#1 cm) \tkzGetFirstPoint{#6}
\endgroup}

\def\TwoSide(#1,#2,#3)(#4,#5,#6){%
\begingroup 
\tkzDefPoints{0/0/#4,#3/0/#5}
\tkzDefPoint(#2:#1){#6}
\endgroup}

\def\OneSide(#1,#2,#3)(#4,#5,#6){%
\begingroup 
\tkzDefPoints{0/0/#4,#2/0/#5}
  \tkzDefPointBy[rotation= center #4 angle \A](#5)
  \tkzGetPoint{a}
  \tkzDefPointBy[rotation= center #5 angle -\B](#4)
  \tkzGetPoint{b}
  \tkzInterLL(#4,a)(#5,b)
  \tkzGetPoint{#6}
\endgroup}
\makeatother

\begin{document} 

\begin{tikzpicture}
  \DefTriangle[SSS={a=4 b=5 c=5}]{A,B,C}
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPoints(A,B,C)
  \tkzLabelPoints[below](A,B)
  \tkzLabelPoints[above](C)
\end{tikzpicture}

\begin{tikzpicture}
  \DefTriangle[SAS={b=4 A=30 c=5}]{D,E,F}
  \tkzDrawPolygon(D,E,F)
  \tkzDrawPoints(D,E,F)
  \tkzLabelPoints[below](D,E)
  \tkzLabelPoints[above](F)
\end{tikzpicture}

 \begin{tikzpicture}
   \DefTriangle[ASA={A=30 c=10 B=60}]{A,B,C}
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPoints(A,B,C)
   \tkzLabelPoints[below](A,B)
   \tkzLabelPoints[above](C)
 \end{tikzpicture}

\end{document} 

enter image description here

A) The simplest solution:

\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}\begin{tikzpicture}
 %def
 \tkzDefPoints{0/0/A,7/0/B}
  \tkzDefPoint(49:5){C}
  % draw
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPoints(A,B,C)
  %marks
  \tkzMarkAngle[size=1.3cm](B,A,C)
  %label
  \tkzLabelSegment[below](A,B){$ 7 $}
  \tkzLabelSegment[left](A,C){$ 5 $}
  \tkzLabelSegment[right](B,C){$ a $}
  \tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
  \tkzLabelPoints(A,B)
  \tkzLabelPoints[above](C)
\end{tikzpicture}
\end{document} 

B) More complicated solution to see some possibilities of the package.

Nothing to say about A and B.

Then you need to use a special value of an angle. You can use a rotation. You get a point c.

The last macro is more subtle ... With the option linear you can get a point on the line Ac with linear normed you get a point C such as AC=1 then with linear normed,K=5 you get AC=5. That's all. You have the three points A,B and C. The you can use tkz-euclide with TikZ's options or you can use only TikZ.

\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
 % def
  \tkzDefPoints{0/0/A,7/0/B}
  \tkzDefPointBy[rotation= center A angle 49](B)
  \tkzGetPoint{c}
  \tkzDefPointWith[linear normed ,K=5](A,c)
  \tkzGetPoint{C}
 % drawing
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPoints(A,B,C)
 % marking
  \tkzMarkAngle[size=1.3cm](B,A,C)
 % labelling
  \tkzLabelSegment[below](A,B){$ 7 $}
  \tkzLabelSegment[left](A,C){$ 5 $}
  \tkzLabelSegment[right](B,C){$ a $}
  \tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
  \tkzLabelPoints(A,B)
  \tkzLabelPoints[above](C)
\end{tikzpicture}
\end{document}

enter image description here

C) minhthien_2016's solution with more tkz-euclide macros

\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}

\begin{tikzpicture}[declare function={a=5;b=7;myAngle=49;}] 
\path (0,0)  coordinate  (B)
({sqrt(a*a+b*b-2*a*b*cos(myAngle))},0)  coordinate  (C)
({b*b -a*b*cos(myAngle))/sqrt(a*a+b*b-2*a*b*cos(myAngle))}
,{a*b*sin(myAngle)/sqrt(a*a+b*b-2*a*b*cos(myAngle))})  coordinate  (A)
;

\tkzDrawPoints(A,B,C)
\tkzLabelPoints(A,B)
\tkzLabelPoints[above](C)
\tkzLabelSegment[above](A,B){$ 7 $}
\tkzDrawPolygon(A,B,C)
\tkzLabelSegment[right](A,C){$ 5 $}
\tkzLabelSegment[below](B,C){$ a $}
\tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
\tkzMarkAngle[size=1.3cm](B,A,C)
\end{tikzpicture}

\end{document}

D) minhthien_2016's solution with only tkz-euclide macros

The problem is $tkz-euclideusesxfpto evaluate the coordinates so I need to determine these coordinates before a call to\tkzDefPoint

\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}

\begin{tikzpicture}[declare function={a=5;b=7;myAngle=49;}] 

\pgfmathparse{sqrt(a*a+b*b-2*a*b*cos(myAngle))}
\let\xc\pgfmathresult
\pgfmathparse{b*b-a*b*cos(myAngle))/sqrt(a*a+b*b-2*a*b*cos(myAngle))}
\let\xa\pgfmathresult
\pgfmathparse{a*b*sin(myAngle)/sqrt(a*a+b*b-2*a*b*cos(myAngle))}
\let\ya\pgfmathresult

\tkzDefPoints{\xa/\ya/A,0/0/B,\xc/0/C}
\tkzDrawPoints(A,B,C)
\tkzLabelPoints(A,B)
\tkzLabelPoints[above](C)
\tkzLabelSegment[above](A,B){$ 7 $}
\tkzDrawPolygon(A,B,C)
\tkzLabelSegment[right](A,C){$ 5 $}
\tkzLabelSegment[below](B,C){$ a $}
\tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
\tkzMarkAngle[size=1.3cm](B,A,C)
\end{tikzpicture}

\end{document}

enter image description here

E) With tkz-euclide and xfp

\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}

\begin{tikzpicture}
\def\a{5}  \def\b{7}  \def\myangle{49}
\tkzDefPoints{{(\b*\b -\a*\b*cos(\myangle))/sqrt(\a*\a+\b*\b-2*\a*\b*cos(\myangle))}%
             /{\a*\b*sin(-\myangle)/sqrt(\a*\a+\b*\b-2*\a*\b*cos(\myangle))}/A,%
               0/0/B,%
              {sqrt(\a*\a+\b*\b-2*\a*\b*cos(\myangle))}/0/C}
\tkzDrawPoints(A,B,C)
\tkzLabelPoints(A,B)
\tkzLabelPoints[above](C)
\tkzLabelSegment[above](A,B){$ 7 $}
\tkzDrawPolygon(A,B,C)
\tkzLabelSegment[right](A,C){$ 5 $}
\tkzLabelSegment[below](B,C){$ a $}
\tkzLabelAngle[pos = 0.8](B,A,C){$49^\circ$}
\tkzMarkAngle[size=1.3cm](B,A,C)
\end{tikzpicture}

\end{document}

F) with three sides

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

\begin{document}
  \begin{tikzpicture}
    \pgfmathsetmacro{\a}{3} % BC
    \pgfmathsetmacro{\b}{5} % AC
    \pgfmathsetmacro{\c}{7} % AB

  \tkzDefPoints{0/0/A,\c/0/B}
  \tkzInterCC[R](A,\b cm)(B,\a cm) \tkzGetFirstPoint{C}
  \tkzDrawPolygon(A,B,C) 
  \tkzLabelSegment[below](A,B){$ 7 $}
  \tkzLabelSegment[above left](A,C){$ 5 $}
  \tkzLabelSegment[above right](B,C){$ 3 $}
  \tkzLabelPoints[below](A,B)
  \tkzLabelPoints[above](C)
\end{tikzpicture}
\end{document}

enter image description here


Here is another version using a pic. You can specify the sides, a, b and c, or two sides and one angle or one side and two angles. It ahould now cover all possible cases. However, if the solution is not unique, it will pick one solution. Also there are not yet sanity checks for all possible inputs in place, but there are some. The code is not very short, this may be the price one has to pay for some sort of user friendliness.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,calc}
\tikzset{pics/triangle/.style={code={
    \tikzset{triangle pars/.cd,#1}%
    \def\pv##1{\pgfkeysvalueof{/tikz/triangle pars/##1}}%
    \edef\lstsides{"a","b","c"}%
    \edef\lstangles{"A","B","C"}%
    \def\tmpundef{undef}%
    \edef\temp{\pv{a}}%
    \ifx\temp\tmpundef
     \edef\nsides{0}%
    \else
     \edef\nsides{1}%
     \edef\firstside{0}%
    \fi
    \edef\temp{\pv{b}}%
    \ifx\temp\tmpundef
    \else
     \edef\nsides{\the\numexpr\nsides+1}%
     \ifnum\nsides=1
      \edef\firstside{1}%
     \else
      \edef\secondside{1}%
     \fi
    \fi
    \edef\temp{\pv{c}}%
    \ifx\temp\tmpundef
    \else
     \edef\nsides{\the\numexpr\nsides+1}%
     \ifnum\nsides=1
      \edef\firstside{2}%
     \else
      \ifcase\nsides
       \or
        \edef\firstside{2}%
       \or
        \edef\secondside{2}%
       \or
        \edef\thirdside{c}%
      \fi 
     \fi
    \fi
    \edef\temp{\pv{A}}%
    \ifx\temp\tmpundef
     \edef\nangles{0}%
    \else
     \edef\nangles{1}%
     \edef\firstangle{0}%
    \fi
    \edef\temp{\pv{B}}%
    \ifx\temp\tmpundef
    \else
     \edef\nangles{\the\numexpr\nangles+1}%
     \ifnum\nangles=1
      \edef\firstangle{1}%
     \else
      \edef\secondangle{1}%
     \fi
    \fi
    \edef\temp{\pv{C}}%
    \ifx\temp\tmpundef
    \else
     \edef\nangles{\the\numexpr\nangles+1}%
     \ifcase\nangles
     \or
      \edef\firstangle{2}%
     \or
      \edef\secondangle{2}%
     \or
      \edef\thirdangle{2}%
     \fi     
    \fi
    \ifnum\numexpr\nangles+\nsides=3 % the number of input parameters is fine
     \ifcase\nsides
      \message{You need to specify at least one side.^^J}
     \or % one side and two angles
      \pgfmathsetmacro{\mysidei}{{\lstsides}[\firstside]}%
      \pgfmathsetmacro{\myanglei}{{\lstangles}[\firstangle]}%
      \pgfmathsetmacro{\myangleii}{{\lstangles}[\secondangle]}%
      \pgfmathtruncatemacro{\thirdangle}{Mod(3-\firstangle-\secondangle,3)}%
      \pgfmathsetmacro{\myangleiii}{{\lstangles}[\thirdangle]}%
      \pgfmathtruncatemacro{\itest}{(\firstside==\firstangle)||(\firstside==\secondangle)}%
      \ifnum\itest=0 % both angles involve known side
        \draw[pic actions] (0,0) 
            coordinate[label=below:$\pv{\myangleii}$] (-B) 
         -- node[midway,auto]{$\mysidei=\pv{\mysidei}$} 
         (\pv{a},0) coordinate (-C) 
         --
          (intersection cs:first line={(-B)--($(-B)+({\pv{\myangleii}}:1)$)},
          second line={(-C)--($(-C)+({-180+\pv{\myanglei}}:1)$)})
          coordinate (-A) -- cycle;   
      \else % one angle is away from the known side
       \ifnum\firstside=\firstangle
        \draw[pic actions] (0,0) 
         coordinate[label=below:$\myangleii$] (-\myangleii) 
         -- node[midway,auto]{$\mysidei=\pv{\mysidei}$} 
         (\pv{a},0) coordinate[label=below:$\myangleiii$] (-\myangleiii) 
         --
          (intersection cs:first line={(-\myangleii)--($(-\myangleii)+({\pv{\myangleii}}:1)$)},
          second line={(-\myangleiii)--($(-\myangleiii)+({-180+\pv{\myanglei}+\pv{\myangleii}}:1)$)})
          coordinate[label=above:$\myanglei$] (-\myanglei) -- cycle
          ($(-\myangleii)+(0:\pv{r})$)arc[start angle=0,end angle=\pv{\myangleii},radius=\pv{r}]
          ($(-\myanglei)+(180+\pv{\myangleii}:\pv{r})$)
          arc[start angle=180+\pv{\myangleii},end angle=180+\pv{\myanglei}+\pv{\myangleii},radius=\pv{r}]
          ;
       \else
        \draw[pic actions] (0,0) 
         coordinate[label=below:$\myanglei$] (-\myanglei) 
         -- node[midway,auto]{\mysidei} 
         (\pv{a},0) coordinate[label=below:$\myangleiii$] (-\myangleiii) 
         --
          (intersection cs:first line={(-\myanglei)--($(-\myanglei)+({\pv{\myanglei}}:1)$)},
          second line={(-\myangleiii)--($(-\myangleiii)+({-180+\pv{\myanglei}+\pv{\myangleii}}:1)$)})
          coordinate[label=above:$\myangleii$] (-\myangleii) -- cycle
          ($(-\myanglei)+(0:\pv{r})$)arc[start angle=0,end angle=\pv{\myanglei},radius=\pv{r}]
          ($(-\myangleii)+(180+\pv{\myanglei}:\pv{r})$)
          arc[start angle=180+\pv{\myanglei},end angle=180+\pv{\myanglei}+\pv{\myangleii},radius=\pv{r}]
          ;
       \fi    
      \fi
     \or % two sides and one angle
      \pgfmathsetmacro{\mysidei}{{\lstsides}[\firstside]}%
      \pgfmathsetmacro{\mysideii}{{\lstsides}[\secondside]}%
      \pgfmathsetmacro{\myanglei}{{\lstangles}[\firstangle]}%
      \pgfmathtruncatemacro{\thirdside}{Mod(3-\firstside-\secondside,3)}%
      \pgfmathsetmacro{\mysideiii}{{\lstsides}[\thirdside]}%
      \pgfmathsetmacro{\myangleii}{{\lstangles}[\secondside]}%
      \pgfmathsetmacro{\myangleiii}{{\lstangles}[\thirdside]}%
      \pgfmathtruncatemacro{\itest}{(\firstside==\firstangle)||(\secondside==\firstangle)}%
      \ifnum\itest=0 % both sides attach to the angle
       \pgfmathsetmacro{\myangleii}{{\lstangles}[\firstside]}%
       \pgfmathsetmacro{\myangleiii}{{\lstangles}[\secondside]}%
       \draw[pic actions] (\pv{\myanglei}:\pv{\mysidei}) 
            coordinate[label=above:$\myangleiii$] (-\myangleiii)
        --   node[midway,auto]{$\mysidei=\pv{\mysidei}$} 
        (0,0) coordinate[label=below:$\myanglei$] (-\myanglei) 
        --  node[midway,auto]{$\mysideii=\pv{\mysideii}$}  
        (\pv{\mysideii},0) coordinate[label=below:$\myangleii$] (-\myangleii)
       --  cycle
       (\pv{r},0) arc[start angle=0,end angle=\pv{\myanglei},radius=\pv{r}];
      \else
       \pgfmathsetmacro{\mya}{max(\pv{\mysidei},\pv{\mysideii})}%
       \pgfmathsetmacro{\myb}{min(\pv{\mysidei},\pv{\mysideii})}%
       \pgfmathsetmacro{\myc}{\myb*cos(\pv{\myanglei})%
        +sqrt(\mya*\mya-pow(\myb*sin(\pv{\myanglei}),2)}%
       \ifnum\firstside=\firstangle
        \draw[pic actions] (\pv{\myanglei}:\myc) 
             coordinate[label=above:$\myangleii$] (-\myangleii)
          --  (0,0) coordinate[label=below:$\myanglei$] (-\myanglei) 
          --  node[midway,auto]{$\mysideii=\pv{\mysideii}$}  
         (\pv{\mysideii},0) coordinate[label=below:$\myangleiii$] (-\myangleiii)
        --  node[midway,auto]{$\mysidei=\pv{\mysidei}$}  cycle
        (\pv{r},0) arc[start angle=0,end angle=\pv{\myanglei},radius=\pv{r}];
       \else
        \pgfmathsetmacro{\myangleii}{{\lstangles}[\thirdside]}%
        \pgfmathsetmacro{\myangleiii}{{\lstangles}[\firstside]}%
        \draw[pic actions] (\pv{\myanglei}:\myc) 
             coordinate[label=above:$\myangleiii$] (-\myangleiii)
          --  (0,0) coordinate[label=below:$\myanglei$] (-\myanglei) 
          --  node[midway,auto]{$\mysidei=\pv{\mysidei}$}  
         (\pv{\mysidei},0) coordinate[label=below:$\myangleii$] (-\myangleii)
        --  node[midway,auto]{$\mysideii=\pv{\mysideii}$}  cycle
        (\pv{r},0) arc[start angle=0,end angle=\pv{\myanglei},radius=\pv{r}];
       \fi
      \fi
     \or %three sides
      %\typeout{3 sides}
      \pgfmathsetmacro{\mymax}{max(\pv{a},\pv{b},\pv{c})}%
      \pgfmathtruncatemacro{\itest}{sign(2*\mymax-\pv{a}-\pv{b}-\pv{c})}%
      \ifnum\itest<1
       \draw[pic actions] (0,0) coordinate[label=below:$B$] (-B) 
        -- node[midway,auto]{$a=\pv{a}$} 
        (\pv{a},0) coordinate[label=below:$C$] (-C) 
         -- node[midway,auto]{$b=\pv{b}$}
        (intersection cs:first line={(-B)--($(-B)+({cosinelaw(\pv{a},\pv{c},\pv{b})}:1)$)},
         second line={(-C)--($(-C)+({-cosinelaw(\pv{a},\pv{b},\pv{c})}:1)$)})
         coordinate[label=above:$A$] (-A) -- 
         node[midway,auto]{$c=\pv{c}$} cycle;
      \else
       \message{a=\pv{a},b=\pv{b},c=\pv{c} is not consistent since one side is
        longer than the sum of two other sides.^^J}
      \fi    
     \fi
    \else
     \message{Incorrect input. You need to specify three parameters.^^J}     
    \fi
    }},
  declare function={cosinelaw(\a,\b,\c)=acos((\a*\a+\b*\b-\c*\c)/(2*\a*\b));},
  triangle pars/.cd,
  A/.initial=undef,B/.initial=undef,C/.initial=undef,% angles
  a/.initial=undef,b/.initial=undef,c/.initial=undef,% sides
  r/.initial=1%radius of angles
  }
\begin{document}
\subsection*{Specify triangle by its three sides}
\begin{tikzpicture}
  \pic{triangle={a=5,b=4,c=3}};
\end{tikzpicture}

\subsection*{Specify triangle by two sides and one angle}
\begin{tikzpicture}
  \pic{triangle={a=5,b=4,A=40}};
\end{tikzpicture}

\begin{tikzpicture}
  \pic{triangle={a=5,b=4,B=40}};
\end{tikzpicture}

\begin{tikzpicture}
  \pic{triangle={a=5,b=4,C=40}};
\end{tikzpicture}


\subsection*{Specify triangle by one side and two angles}
\begin{tikzpicture}
  \pic{triangle={a=5,A=60,B=70}};
\end{tikzpicture}

\begin{tikzpicture}
  \pic{triangle={a=5,A=60,C=70}};
\end{tikzpicture}

\end{document}

enter image description here

enter image description here

Tags:

Tikz Pgf