# Create triangle solving problems

I am hoping to create a triangle-solving problem generator, similar to the one here.

My goal is to automatically generate different triangle solving problems for my students. Say given A=49°, b=5 and c=7, I am hoping that the program will generate the picture below. Similarly it would be great for the system to allow me to enter the triangle data by other axioms such as SSS, ASA.

I have tagged tikz-pgf here but other drawing languages are welcome.

• Are you willing to pay for this software development? – Thruston Feb 26 at 20:34
• @Thruston, I am afraid not... I am hoping to find a good Samaritan here. – Zuriel Feb 26 at 20:45
• This already has been achieved in this answer. I plan adjusting the code to your problem a bit later. – Schrödinger's cat Feb 26 at 20:51
• @Schrödinger'scat, thank you so much!! – Zuriel Feb 26 at 21:03
• I've find all six possible cases in Keit, Oldham,Myland and Spanier - An Atlas of Functions pag. 349 (without proofs). – vi pa Feb 27 at 10:08

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}


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}


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

}
\begin{document}
\pagestyle{empty}
\section{SSS} %the sum of any two sides must less then the third side.
\tikz{\SSS{3}{4}{5}}

\section{SAS} %the angle must be less than 180
\tikz{\SAS{5}{40}{4}}

\section{ASA} %the sum of two angle must be less then 180
\tikz{\ASA{30}{5}{40}}

\section{AAS} %the sum of two angle must be less then 180
\tikz{\AAS{30}{40}{5}}

\section{SsA} %S must be greater or equal to s. If S is equal to s (isoscele triangle) the angle must be less then 90
\tikz{\SsA{5}{4}{40}}

\section{sSA} %S must be greater or equal to s. In this case it's possible to draw two different triangles.
%If S is equal to s (isoscele triangle) the triangle is unique and the same as SsA.
%The angle A must be less then arcsin(s/S)
\begin{tabular}{ll}
\tikz{\sSAfirst{4}{5}{40}}&
\tikz{\sSAsecond{4}{5}{40}}\\
\end{tabular}
\end{document}