Backyard trig

The Problem

I used to teach college trigonometry every year or so, and I loved to supplement the course with my own hand-made applications. I happen to own an old sextant (the Davis Mark 3), and one day I decided to use it to see if I could figure out the height of a tall tree in my yard.

With the sextant, I could measure the “visual angle” of the tree from various distances away. However, I had to be quite far from the tree in order to see its top, so I couldn’t measure both the visual angle and my distance from the tree simultaneously (I only had a 12-foot measuring tape). From some large distance away, the visual angle of the tree was about 40.3°. From 12 feet closer, it was about 46.02°. From another 12 feet closer, it was about 53.55°. Since the grass was wet with dew at the time, I had to measure each of these angles from eye height, 6 feet above the ground.

So, how tall is the tree? When I took the measurements I assumed, without thinking much about it, that there would be a straightforward method of using them to find the tree’s height. Now as far as I can tell, that’s not actually the case. But here are two very different approaches for finding the tree’s height with some light technological help.

Approach 1: Error Minimization

scipyWith Python and SciPy, we can use a kind of automated “guess and check” method to home in on the tree’s height. Let’s say my measurements were taken from the points (0, 6), (12, 6), and (24, 6). If I guess that the top of the tree is at a certain point P, I can find the visual angles the tree should have, and compare them to the actual measurements. Then I can adjust the guessed position P in some intelligent way and try again until the predicted visual angles match up as well as possible with the observed visual angles.

The following function calculates a kind of “error” for any given guess P, measuring how far off the predicted visual angles are.

from scipy.optimize import minimize
from numpy import arctan, radians

def tree_error(P):
    # Error function.
    # Input: Estimated point P at the top of the tree.

    # Get coordinates of P.
    x, y = P

    # Calculate the three visual angles for P, in degrees
    # ( angle = depression to ground   +   elevation to P ).
    angle1    = arctan(6/x)            +   arctan((y-6)/x)
    angle2    = arctan(6/(x-12))       +   arctan((y-6)/(x-12))
    angle3    = arctan(6/(x-24))       +   arctan((y-6)/(x-24))

    # Calculate "error" as the sum of squared differences 
    # from the observed angles.
    err  = (angle1 - radians(40.3))**2 
    err += (angle2 - radians(46.02))**2 
    err += (angle3 - radians(53.55))**2
    return err

With this function defined, the following line uses a sophisticated guess-and-check process to find the best guess for P, with a starting guess of (50, 50).

print(minimize(tree_error, [50,50]))

The result is close to (74, 59), so the tree seems to be about 59 feet tall.

Approach 2: Interactive Simulation

We can use GeoGebra to create a model of the situation, based on my measurements. Here are the steps you might take:

  1. Open the GeoGebra app and create points A = (0,6), B = (12,6), and C = (24,6).
  2. Create a point D on the x-axis and join it to the first three points with line segments.
  3. Create rays from each of the first three points that make the appropriate angles with the segments from step 2 (the GeoGebra commands are Ray[A,Rotate[D,40.3°,A]], Ray[B,Rotate[D,46.02°,B]], and Ray[C,Rotate[D,53.55°,C]]).
  4. Create a ray upward from point D (GeoGebra command Ray[D,D+(0,1)]).
  5. Drag point D until the rays from steps 3 and 4 all intersect at roughly the same point. The height of that point should be a good approximation of the height of the tree.

The result is a tree height of about 59 feet.

tree_sim
Click to see the interactive version.