# Triangles

## Overview

Triangle geometry pops up time and time again in engineering, in all sorts of things such as robotics, motors, linkages, maps, and sensing (e.g. GPS or ultrasound). It’s helpful to know how to work with triangles and solve for things like unknown side lengths and angles, areas, e.t.c.

This page will teach you how! If you have a right-angles triangle and what to calculate unknown edge lengths or angles, use the basic trigonometric ratios (SOH CAH TOA). If you have a non-right angled triangle (an oblique triangle) but want to also want to solve for lengths and/or angles, use the Law of Sines and/or Law of Cosines.

## Trigonometric Ratios

Trigonometric ratios are the three ratios $\sin$, $\cos$, and $\tan$ which are defined using properties of a right-angled triangle (a triangle in which one of the internal angles is $90^{\circ}$). They are useful for solving for unknown side lengths and angles of right-angled triangles, but they also crop up many other situations such as Fourier Series, AC voltage/current, complex numbers (e.g. Euler’s formula) and oscillators.

### The Equations

Given you have a triangle with a right-angle in it, and another angle $A$, then the image below shows the naming of the triangle’s sides when using trigonometric ratios.

It might be obvious from the figure, but the names are because:

• The hypotenuse is the longest side of the right-angled triangle (it is always opposite the right-angle).
• The opposite side is the side opposite angle $A$.
• The adjacent side if the side next to angle $A$ (but not the hypotenuse).

Using these names, then the trigonometric ratios $\sin$, $\cos$, and $\tan$ are defined as:

\begin{align} \sin A &= \frac{\text{opposite}}{\text{hypotenuse}} \\ \cos A &= \frac{\text{adjacent}}{\text{hypotenuse}} \\ \tan A &= \frac{\text{opposite}}{\text{adjacent}} \\ \end{align}

There are normally just shortened to:

\begin{align} \sin A &= \frac{O}{H} \\ \cos A &= \frac{A}{H} \\ \tan A &= \frac{O}{A} \\ \end{align}

## Law of Sines

### The Equation

The Law of Sines is a useful equation for determining unknown lengths and angles of any triangle (not just right-angled triangles) if you know some of the other lengths and angles. Together with the Law of Cosines you can find the lengths and angles of any triangle as long as you know enough values already to fully-constrain it.

If a triangle has lengths of $a$, $b$, and $c$ and opposite angles of $A$, $B$, and $C$ respectively (as shown in the above diagram), then the Law of Sines is:

\begin{align} \frac{\sin{A}}{a} = \frac{\sin{B}}{b} = \frac{\sin{C}}{c} \end{align}

This means that the sine of the angle divided by the opposite length is the same value for all three angle/side pairs.

### What Are Opposite Angles?

The opposite angle for any side of a triangle is the angle which does not “touch” the side in question. For example, if $a$ was a side of a triangle, then it’s opposite angle $A$ would be the angle enclosed by sides $b$ and $c$. The angle is directly “opposite” the side.

### Multiple Solutions (Ambiguity)

In certain circumstances, there is more than one possible answer when calculating values using the Law of Sines. This occurs in a specific situation, when1:

• You know the length of two sides of the triangle ($a$ and $b$) and one opposite angle $A$ (and thus are trying to calculate the other opposite angle $B$).
• Angle $A$ is in the range $0^{\circ} < A < 90^{\circ}$ (i.e. is acute).
• Length $a$ is greater than $h$ but less than $b$, where $h$ is the “vertical” height as shown below:

Mathematically this occurs because $\sin^{-1}$ can give two answers in the range of $[0, 180]$ (a valid angle of a triangle has to be within this range). For example, $\sin^{-1}(0.6)$ gives the following values:

\begin{align} \sin^{-1}(0.6) &= 36.9^{\circ} && \text{This is what the calculator will give you} \\ \sin^{-1}(0.6) &= 180.0^{\circ} - 36.9^{\circ} \\ &= 143.1^{\circ} \\ \end{align}

Calculators always give you the angle in the range of $[-90, 90]$ when using $\sin^{-1}$ (also called $asin$ or $arcsin$). To get the other answer you have to subtract the calculator answer from $180^{\circ}$. The image below explains the situation in visual manner.

Ambiguity is not a problem if A is in the range $90^{\circ} \leq A < 180^{\circ}$ (i.e. $A$ is not acute). In this scenario, There can either be no solution or just 1 solution, but never 2. The image below illustrates this.

If you find yourself in a position with two possible answers, what can you do? If you don’t have any other information about the triangle, then you are out of luck. However, if you know the length of the remaining side of the triangle, you can use the Cosine Law to completely solve for all angles and sides of the triangle. If you know one other angle of the triangle, then you can use the simple fact that all the internal angles sum to $180^{\circ}$ to solve for the angle you were interested in.

## Law of Cosines

The Law of Cosines (also known as the cosine formula or cosine rule2) is an equation similar to the Law of Sines which lets you calculate unknown sides and opposite angles of any triangle (not just right-angled triangles) if you know some of the others.

### The Equation

The Law of Cosines equation is:

\begin{align} c^2 &= a^2 + b^2 - 2ab\cos{C} \\ \end{align}

where:
$a$, $b$ and $c$ are side lengths of the triangle
$C$ is the opposite angle of side $c$

The image below shows the side and angles involved in the Law of Cosines equation. Knowing all but one of these values, you can calculate the last one by re-arranging the equation.

The law of cosines is useful for solving the sides and angles of a triangle when all three sides are known, or two sides and their included angle are known. If you know two angles and a side, or two sides and an angle other than the included angle, use the law of sines instead.

Here is the Law of Cosines equation rearranged for all sides and angles2:

\begin{align} a &= b\cos C \pm \sqrt{c^2 - b^2 \sin^2 C} \\ \label{law-of-cosines-solve-for-b} b &= a\cos C \pm \sqrt{c^2 - a^2 \sin^2 C} \\ c &= \sqrt{a^2 + b^2 - 2ab\cos{C}} \\ C &= \cos^{-1}\left( \frac{a^2 + b^2 - c^2}{2ab} \right) \\ \end{align}

Because the side and opposite angle pairs can be assigned freely around the triangle, the equation for $b$ is essentially the same as for $a$. Note that for both of these sides, there may be 0, 1 or 2 solutions.

The Law of Cosines can be thought of as a generalization of Pythagorean Theorem (the Pythagorean Theorem is the equation $c^2 = a^2 + b^2$ that applies to right-angled triangles).

If we start with the Law of Cosines equation and then make the angle $C = 90^{\circ}$ it reduces down to the Pythagorean equation:

\begin{align} c^2 &= a^2 + b^2 - 2ab\cos{C} \nonumber \\ c^2 &= a^2 + b^2 - 2ab\cos{90^{\circ}} \nonumber \\ c^2 &= a^2 + b^2 - 2ab\cdot 0 \nonumber \\ c^2 &= a^2 + b^2 \\ \end{align}

### Multiple Solutions (Ambiguity)

Just like the Law of Sines, the Law of Cosines can also have multiple solutions. And just like with the Law of Sines, multiple solutions can only occur if you know the length of two sides and one opposite angle.

## Calculators

Google has handy Law of Sines/Cosines calculators that pops up when you search “law of sines”/“law of cosines”. The image below shows a screenshot of the Law of Cosines calculator.

The eMathHelp Law of Cosines calculator as shown below is different from most and shows you the working to solve the triangle. They also has a Law of Sines calculator.

## Footnotes

1. Libretexts: Mathematics. 2.1: The Law of Sines. Retrieved 2023-12-31, from https://math.libretexts.org/Bookshelves/Precalculus/Elementary_Trigonometry_(Corral)/02%3A_General_Triangles/2.01%3A_The_Law_of_Sines

2. Wikipedia (2023, Dec 27). Law of cosines. Retrieved 2024-01-03, from https://en.wikipedia.org/wiki/Law_of_cosines. 2