Function Repository Resource:

ASSTriangles

Source Notebook

Create a list of all triangles with side lengths a and b and angle β opposite the side with length b

Contributed by: Ted Ersek

ResourceFunction["ASSTriangles"][β,a,b]

returns a list of all triangles with sides of lengths a and b and angle β opposite the side with length b.

Details

ASSTriangles are known as angle-side-side triangles or side-side-angle triangles.
ResourceFunction["ASSTriangles"][β,a,b] assumes angle β is in radians.
ASSTriangles returns either a list of two triangles, a list of one triangle, or an empty list.
When ASSTriangles returns a non-empty list the elements have the head Triangle.
When ASSTriangles returns an empty list there are no triangles with the specified values for angle, side, side where the second side is opposite the specified angle.
Triangles returned by ASSTriangles have angle β at the origin and the side with length = a along the positive horizontal axis.
ASSTriangles allows angle β strictly between 0 and π and lengths a, b to be any positive number.

Examples

Basic Examples (5) 

There are two triangles with the specified angle, side, side for this example:

In[1]:=
{triangle1, triangle2} = ResourceFunction["ASSTriangles"][38.0 °, 6, 4]
Out[1]=

The triangles above are the black outline and the gray triangle below:

In[2]:=
Graphics[{GrayLevel[0.9], triangle2, Black, Sequence[
Circle[{0, 0}, {0.85, 0.85}, {3 Degree, 33. Degree}], 
Text[
Style["38°", 14], {1.1, 0.33}], 
Text[
Style["6", 14], {3, -0.2}], 
Text[
Style["4", 14], {5.65, 1.9}], 
Text[
Style["4", 14], {4.15, 1.2}], 
AbsoluteThickness[2]], Line[Join[Part[triangle1, 1], {Part[triangle1, 1, 1]}]]}, Sequence[
 AspectRatio -> Automatic, PlotRange -> All]]
Out[2]=

The next two cells verify that both triangles above have the specified angle, side, side:

In[3]:=
{p1, p2, p3} = Part[triangle1, 1];
{Apply[ArcTan, p3]*180/\[Pi], Norm[p1 - p2], Norm[p2 - p3]}
Out[4]=
In[5]:=
{p1, p2, p3} = Part[triangle2, 1];
{Apply[ArcTan, p3]*180/\[Pi], Norm[p1 - p2], Norm[p2 - p3]}
Out[6]=

Only one triangle has the specified angle side, side in this example:

In[7]:=
triangle = ResourceFunction["ASSTriangles"][80.0 °, 5, 7]
Out[7]=
In[8]:=
Graphics[{White, EdgeForm[{
AbsoluteThickness[2], Black}], First@triangle, Sequence[Black, 
Circle[{0, 0}, {0.5, 0.5}, {6 Degree, 74 Degree}], 
Text[
Style["80°", 14], {0.67, 0.38}], 
Text[
Style["5", 14], {2.5, -0.16}], 
Text[
Style["7", 14], {3.1, 3}]]}, Sequence[
 AspectRatio -> Automatic, PlotRange -> All]]
Out[8]=

The next cell verifies the triangle above has the specified angle, side, side:

In[9]:=
{p1, p2, p3} = Part[triangle, 1, 1];
{Apply[ArcTan, p3]*180/\[Pi], Norm[p1 - p2], Norm[p2 - p3]}
Out[10]=

ASSTriangles always returns one obtuse triangle when the specified angle is 90° or greater and the third argument is greater than the second argument. An example is in the next cell:

In[11]:=
obtuseTriangle = ResourceFunction["ASSTriangles"][145.0 °, 3, 6]
Out[11]=
In[12]:=
Graphics[{Sequence[White, 
EdgeForm[{
AbsoluteThickness[2], Black}]], First@obtuseTriangle, Sequence[
  Black, 
Circle[{0, 0}, {0.2, 0.2}, {6 Degree, 142 Degree}], 
Text[
Style["145°", 12], {0.2, 0.25}], 
Text[
Style["3", 14], {1.5, -0.12}], 
Text[
Style["6", 14], {0.5, 0.93}]]}, AspectRatio -> Automatic]
Out[12]=

The next cell verifies the triangle above has the specified angle, side, side:

In[13]:=
{p1, p2, p3} = Part[obtuseTriangle, 1, 1];
{Apply[ArcTan, p3]*180/\[Pi], Norm[p1 - p2], Norm[p2 - p3]}
Out[14]=

The next example makes a (3,4,5) right triangle:

In[15]:=
{rightTraingle} = ResourceFunction["ASSTriangles"][ArcTan[4/3], 5, 4]
Out[15]=
In[16]:=
Graphics[{Sequence[White, 
EdgeForm[{
AbsoluteThickness[2], Black}]], rightTraingle, Sequence[Black, 
Text[
Style["3", 14], {0.78, 1.2}], 
Text[
Style["4", 14], {3.3, 1.4}]]}, Sequence[
 Axes -> True, AspectRatio -> Automatic]]
Out[16]=

The next cell verifies the triangle above has the specified angle, side, side:

In[17]:=
{p1, p2, p3} = Part[rightTraingle, 1];
{ArcCos[p3 . (p2 - p3)] 180/\[Pi], Norm[p1 - p2], Norm[p2 - p3]}
Out[18]=

The next example is a case where no triangle has the specified angle, side, side:

In[19]:=
ResourceFunction["ASSTriangles"][40 °, 6, 3.3]
Out[19]=

In this example we would have a right triangle if the last argument of ASSTriangles was 6 Sin[40°]≈3.85673. The next graphics illustrates why no triangle has the angle, side, side specified in the last example:

In[20]:=
Graphics[{AbsoluteThickness[2], Line[{3.9 { Cos[40 °], Sin[40 °]}, {0, 0}, {6, 0}, {6 + 3.3 Cos[140 °], 3.3 Sin[140 °]}}],
  Sequence[
Circle[{0, 0}, {0.5, 0.5}, {7 Degree, 33 Degree}], 
Text[
Style["40°", 14], {0.75, 0.22}], 
Text[
Style["6", 14], {3, -0.2}], 
Text[
Style["3", 14], {4.74, 1.3}]]}, AspectRatio -> Automatic]
Out[20]=

Scope (4) 

When ASSTriangles is given exact input it returns exact results:

In[21]:=
ResourceFunction["ASSTriangles"][30 °, 5, 3]
Out[21]=

When ASSTriangles is given values with many digits of precision it returns results with all digits that can be be justified:

In[22]:=
ResourceFunction["ASSTriangles"][30 °, 5, N[3, 35]]
Out[22]=

When one or more argument is symbolic and non-numeric ASSTriangles does nothing to change the input:

In[23]:=
triangles = ResourceFunction["ASSTriangles"][15 °, a, b]
Out[23]=

We can use replacement rules to assign specific values for a, b in triangles above:

In[24]:=
triangles /. {a -> 5, b -> 3.0}
Out[24]=

We can also use Blockto assign values to a, b in triangles above:

In[25]:=
Block[{a = 5, b = 3.0}, triangles]
Out[25]=

ASSTriangles displays an error message and returns the original input when given incorrect:

In[26]:=
ResourceFunction["ASSTriangles"][30 °, 5, Sqrt[2] + I]
Out[26]=

No message is displayed in the next example because it would give a list of Triangles if b had an appropriate value:

In[27]:=
ResourceFunction["ASSTriangles"][30 °, 5, b + I]
Out[27]=

Neat Examples (1) 

The next example allows you to see the result of providing ASSTriangles any values for three arguments:

In[28]:=
Manipulate[
 DynamicModule[{triangles, failed = False}, Quiet[triangles = Check[ResourceFunction["ASSTriangles"][\[Beta] °, a, b], failed = True]];
  Which[failed, Pane[Style["ASSTriangles was given invalid arguments", 18, Bold], Sequence[
    ImageSize -> {200, 100}, Alignment -> {Center, Center}]],
   failed = False; Length[triangles] == 1,
   Graphics[{White, 
EdgeForm[{
AbsoluteThickness[2], Black}], 
First[triangles]}, PlotLabel -> "One triangle", AspectRatio -> Automatic, Axes -> True, ImageSize -> {200, 100}],
   Length[triangles] == 2,
   Graphics[{GrayLevel[0.9], Last@triangles, AbsoluteThickness@2, Opacity[1, Black], Line[Join[Part[triangles, 1, 1], {Part[triangles, 1, 1, 1]}]]}, AspectRatio -> Automatic, Axes -> True, ImageSize -> {200, 100}, PlotRange -> All, PlotLabel -> "Two triangles."],
   True, Pane[Style["No solution.", 18], ImageSize -> {200, 100}, Alignment -> {Center, Center}]
   ]],
 {{\[Beta], 60}, 2, 175}, {{a, 4}, 0.3, 8}, {{b, 6}, 1, 8}
 ]
Out[28]=

Publisher

Ted Ersek

Version History

  • 1.0.1 – 02 October 2023
  • 1.0.0 – 04 November 2022

Related Resources

License Information