Skip to content

Triangles

Published On:
Dec 29, 2023
Last Updated:
Jan 7, 2024

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\sin, cos\cos, and tan\tan which are defined using properties of a right-angled triangle (a triangle in which one of the internal angles is 9090^{\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 AA, then the image below shows the naming of the triangle’s sides when using trigonometric ratios.

Diagram illustrating the naming of the triangles sides w.r.t. to angle A 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 AA.
  • The adjacent side if the side next to angle AA (but not the hypotenuse).

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

sinA=oppositehypotenusecosA=adjacenthypotenusetanA=oppositeadjacent\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:

sinA=OHcosA=AHtanA=OA\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.

Diagram illustrating the variables used in the Law of Sines.

If a triangle has lengths of aa, bb, and cc and opposite angles of AA, BB, and CC respectively (as shown in the above diagram), then the Law of Sines is:

sinAa=sinBb=sinCc\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 aa was a side of a triangle, then it’s opposite angle AA would be the angle enclosed by sides bb and cc. 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 (aa and bb) and one opposite angle AA (and thus are trying to calculate the other opposite angle BB).
  • Angle AA is in the range 0<A<900^{\circ} < A < 90^{\circ} (i.e. is acute).
  • Length aa is greater than hh but less than bb, where hh is the “vertical” height as shown below:
Diagram showing the situations when you know two sides of the triangle and 1 opposite angle. c) is the ambiguous cases which has two possible solutions.

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

sin1(0.6)=36.9This is what the calculator will give yousin1(0.6)=180.036.9=143.1\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][-90, 90] when using sin1\sin^{-1} (also called asinasin or arcsinarcsin). To get the other answer you have to subtract the calculator answer from 180180^{\circ}. The image below explains the situation in visual manner.

Graph showing how inverse sine can result in two values between [0,180][0, 180].

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

Diagram showing that when A is not acute, there is no ambiguous case for the Law of Sines.

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 180180^{\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:

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

where:
aa, bb and cc are side lengths of the triangle
CC is the opposite angle of side cc

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.

Diagram showing the sides and angles involved in the Law of Cosines.

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:

a=bcosC±c2b2sin2Cb=acosC±c2a2sin2Cc=a2+b22abcosCC=cos1(a2+b2c22ab)\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 bb is essentially the same as for aa. 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 c2=a2+b2c^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=90C = 90^{\circ} it reduces down to the Pythagorean equation:

c2=a2+b22abcosCc2=a2+b22abcos90c2=a2+b22ab0c2=a2+b2\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.

Screenshot of the Law of Cosines calculator Google provides when you search “law of cosines”3.

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.

Screenshot of the Law of Cosines calculator from eMathHelp that shows the step-by-step working to the solution4.

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

  3. Google. Law of Cosines [Search Results]. Retrieved 2024-01-03, from https://www.google.com/search?q=law+of+cosines.

  4. eMathHelp (2024). Law of Cosines Calculator - Solve triangles using the law of cosines. Retrieved 2023-01-06, from https://www.emathhelp.net/en/calculators/geometry/law-of-cosines-calculator/.