public function endpoint(Position $start, float $heading, Distance $distance): Position
    {
        $lat = \deg2rad($start->latitude());
        $lng = \deg2rad($start->longitude());

        $angularDistance = $distance->meters() / Earth::RADIUS;
        $heading = \deg2rad($heading);

        $lat2 = \asin(
            \sin($lat) * \cos($angularDistance) +
            \cos($lat) * \sin($angularDistance) * \cos($heading)
        );
        $lon2 = $lng + \atan2(
            \sin($heading) * \sin($angularDistance) * \cos($lat),
            \cos($angularDistance) - \sin($lat) * \sin($lat2)
        );

        return new Position(\rad2deg($lon2), \rad2deg($lat2));
    }
public function endpoint(Position $start, float $heading, Distance $distance): Position
    {
        $lat = \deg2rad($start->latitude());
        $lng = \deg2rad($start->longitude());

        $angularDistance = $distance->meters() / Earth::RADIUS;
        $heading = \deg2rad($heading);

        $lat2 = \asin(
            \sin($lat) * \cos($angularDistance) +
            \cos($lat) * \sin($angularDistance) * \cos($heading)
        );
        $lon2 = $lng + \atan2(
            \sin($heading) * \sin($angularDistance) * \cos($lat),
            \cos($angularDistance) - \sin($lat) * \sin($lat2)
        );

        return new Position(\rad2deg($lon2), \rad2deg($lat2));
    }
public function endpoint ( Position $ start , float $ heading , Distance $ distance ) : Position { $ lat = \ deg2rad ( $ start -> latitude ( ) ) ; $ lng = \ deg2rad ( $ start -> longitude ( ) ) ; $ angularDistance = $ distance -> meters ( ) / Earth :: RADIUS ; $ heading = \ deg2rad ( $ heading ) ; $ lat2 = \ asin ( \ sin ( $ lat ) * \ cos ( $ angularDistance ) + \ cos ( $ lat ) * \ sin ( $ angularDistance ) * \ cos ( $ heading ) ) ; $ lon2 = $ lng + \ atan2 ( \ sin ( $ heading ) * \ sin ( $ angularDistance ) * \ cos ( $ lat ) , \ cos ( $ angularDistance ) - \ sin ( $ lat ) * \ sin ( $ lat2 ) ) ; return new Position ( \ rad2deg ( $ lon2 ) , \ rad2deg ( $ lat2 ) ) ; }
Calculates the destination point along a geodesic, given an initial
heading and distance, from the given start point.

@see http://www.movable-type.co.uk/scripts/latlong.html
Calculates the destination point along a geodesic given an initial heading and distance from the given start point .