I need to calculate whether or not a given coordinate is in front of, or behind another coordinate with bearing, and get the distance.
I've been working on this for a full day at this point and don't seem to be able to get a reliable answer, clearly my geometry skills are lacking!
enum RelativePosition {
case behind(distance: Double)
case inFront(distance: Double)
case equal
}
extension CLLocationCoordinate2D {
func relativeTo(point: CLLocationCoordinate2D, bearing: Double) -> RelativePosition {
// what should this be?
}
}
Any help hugely appreciated.