Using basic trigonometry to measure distance

Within our Quick Measure App we use basic trigonometry to calculate distance. You input the height of your device, point your phone at the base of an object and then the app gives you the distance to that object. Below I explain how this calculation is done within the app.

If we look at the scenario where you are pointing your phone at the base of an object, we can create a right angled triangle:

Trigonometry2

Where:

A    = height of your phone from the ground

B    = distance to the object

c = the angle you are holding your phone from horizontal

I won’t go into detail here about trigonometry and how it works. You’ll just have to trust me that one of the rules of trigonometry is that in the above triangle:

Tan ( e ) = A / B

Or re-arranged:

B (distance) = A (height) /tan ( e )

Therefore, to calculate B (distance) we need to know the value of A (height) and angle e. (tan is a trigonometric function which you should be able to find on a decent calculator, just make sure you are calculating using degrees not radians).

Within our app Quick Measure we know A. You input this when we ask for the height at which you are holding your device.

So what is angle e?

Another rule which we use here is that all angles within a triangle add up to 180 degrees. Therefore, as this is a right angled triangle, one of the three angles is 90 degrees and:

angle e  + angle d = 90 degrees.

Angle c + angle d make a right angle, and therefore add up to 90 degrees. As we know angles e + d also equal 90 degrees we can deduce that:

Angle e = Angle c

The app knows the angle c as it uses the sensors within your phone to determine the angle at which you are holding your phone from horizontal.

We now have everything we need to carry out the calculation and show you the answer on screen. Simple!

Worked example:

Say you point your phone at the base of an object and you are holding it 1.5m from the ground at an angle of 45 degrees.

Distance = 1.5m/tan(45) = 1.5m.

 Download Quick Measure from the Google Play store.