public function calculate(N\LatLong $point1, N\LatLong $point2)
{
$celestialBody = $this->getCelestialBody();
$deltaLat = $point2->getLatitude()->get() - $point1->getLatitude()->get();
$deltaLong = $point2->getLongitude()->get() - $point1->getLongitude()->get();
$a = sin($deltaLat / 2) * sin($deltaLat / 2) + cos($point1->getLatitude()->get()) * cos($point2->getLatitude()->get()) * sin($deltaLong / 2) * sin($deltaLong / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$d = $celestialBody->volumetricMeanRadius * $c * 1000;
return $d;
}
public function testCalculate() { $Haversine = new C\Haversine(); $point1 = new N\LatLong(new N\Coordinate(80.90000000000001), new N\Coordinate(20.1)); $point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.90000000000001)); $metres = $Haversine->calculate($point1, $point2); $this->assertEquals(7303552.8457791, $metres, '', 0.2); }