Calculate the mean bearing of two bearings (from, to)

mean_bearing(from, to)

Arguments

from

The start bearing, counted clockwise from North

to

The end bearing, counted clockwise from North

Value

The mean of the two bearings as decimal degrees within [0..360[

Examples

testthat::expect_equal(mean_bearing(NA, 10), NA)
testthat::expect_equal(mean_bearing(10, NA), NA)
testthat::expect_equal(mean_bearing(0, 20), 10)
testthat::expect_equal(mean_bearing(20, 60), 40)
testthat::expect_equal(mean_bearing(60, 0), 210)