Wednesday 2 September 2020

Haversine

I think I'll be a little out of my depth on this one. I'm reasonably confident that I could have done the calculations when I was at Peak Trigonometry towards the end of my very expensive secondary education aged about 17. The haversine formula is designed to calculate the distance between two points given their respective Latitude N/S and Longitude E/W. On flat surfaces you can do it with Pythagoras [a2 + b2 = h2] as the hypoteneuse of a triangle:
distance = sqrt[(lat1-lat2)2+(lon1-lon2)2].
For spherical trig it's more complicated:
a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where φ is latitude, λ is longitude, R is earth’s radius. But that simplifies down to Pythagoras for local distances.

I didn't really want the haversine but rather the compass-bearing between two points given their respective Latitude and Longitude. Because we were up the hill again on Friday trying to clear some of the noxious invasive species to make the habitat more suitable for sheep and the other indigenous species of Dry Heath. I think it's correct to say that, without sheep, there would be no long-term dry heath, which is really a transition state between bog and forest . . . kept in suspended animation because the sheep eat all the tree shootlets and saplings. There's 200 hectares to clear which cannot be done in a year without hundreds of person days of work. And the whole project is a pilot study to determine what are feasible / efficient methods of achieving you aims: be that fencing, pest-control, habitat modification, saving wild-life, reducing the carbon-footprint, increasing income.

We have agreed to clear ferns Pteridium aquilinum and bushes Ulex europaeus from the most accessible Southernmost corner of the common. Looking at the map we all knew the location of the end-points of the red line which marks the indeterminate N boundary of the area to be cleared. But there is a big hump of hill between the two corners of forestry so nobody can get line of sight between the two ends and nobody wants to cut more than they need to. The other boundaries are defined by stone walls, fences and roadways; so that's easy. Now you could do it with a scientific calculator, or indeed with trig tables in a book like we did in the early 1970s:
θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)
But you can also google up the problem in the hope of finding server which will do it for you. And you can also find a second independent site against which to verify the answer of the first. The bearing is 249° or WSW in old money.
With the book-learning finished, someone has to go out on the hill and put up a series of markers so that nobody unwittingly strays out of the designated official habitat restoration area. Unsurprisingly that someone became me as soon as I communicated my calcs to our commonage chair. Saturday forenoon saw us up on the hill with out kit:
  • smart phone with compass app and GPS LatLong app
  • 100cm technical-drawing T-square to point the phone more precisely on 249° 
  • a generous handful (we needed 9) of 180cm bamboos with red-&-white plastic bag strips as gonfalon (all the better to see you by)
  • 600 m of "string" = electric fence wire [light, white and available
The haversine distance to cover was only 540m but the ground rose quite steeply from the East End of our transect and the horizon on 249° was less than 60m away. You really need two people: one operating the range-finder aka pointing the long-arm of the T-square and directing the other left-a-bit, right-a-bit. You don't need to be super-accurate because if you're 1-2° off you're "only" 2-3% off bearing at the end of the transect. Check you sin tables!
Angle Sin O/H Tan O/A
0.017 0.017
0.035 0.035
As you see, for small angles, sin and tan are effectively the same. Over 500m an error of 2° is about 20m which is a lot if you're a surveyor deciding on how big two adjacent gardens should be but nothing-at-all to replicate an arbitrary line through the bushes drawn on somebody's desk-copy of google maps. And eeee I were dead chuffed when we came over the last brow of the hill and I found that our line of string was pointing straight[ish] at the required corner of the destination forest. I'll give myself another medal with Bob The Surveyor 2o2o on the obverse and a sextant on the other side.

No comments:

Post a Comment