/** * testCalculateInitialAndFinalBearingReturnsExpectedValue * * @param LatLong $latLong The starting point. * @param LatLong $destination The destination. * @param float $expectedInitial The expected initial bearing. * @param float $expectedFinal The expected final bearing. * * @dataProvider getLatLongsWithBearings */ public function testCalculateInitialAndFinalBearingReturnsExpectedValue(LatLong $latLong, LatLong $destination, $expectedInitialBearing, $expectedFinalBearing) { $this->assertEquals($expectedInitialBearing, $latLong->calculateInitialBearing($destination)); $this->assertEquals($expectedFinalBearing, $latLong->calculateFinalBearing($destination)); }
/** * Calculate the final bearing to follow from this point to arrive at the given destination. * * @param LatLong $destination The destination. * * @return float The bearing in decimal degrees. */ public function calculateFinalBearing(LatLong $destination) { $initialBearing = $destination->calculateInitialBearing($this); return fmod($initialBearing + 180, 360); }