1 | <?php |
||
16 | class BearingSpherical implements BearingInterface |
||
17 | { |
||
18 | /** |
||
19 | * Earth radius in meters. |
||
20 | */ |
||
21 | private const EARTH_RADIUS = 6371009.0; |
||
22 | |||
23 | /** |
||
24 | * This method calculates the initial bearing between the |
||
25 | * two points. |
||
26 | * |
||
27 | * @param Coordinate $point1 |
||
28 | * @param Coordinate $point2 |
||
29 | * |
||
30 | * @return float Bearing Angle |
||
31 | */ |
||
32 | public function calculateBearing(Coordinate $point1, Coordinate $point2): float |
||
50 | |||
51 | /** |
||
52 | * Calculates the final bearing between the two points. |
||
53 | * |
||
54 | * @param Coordinate $point1 |
||
55 | * @param Coordinate $point2 |
||
56 | * |
||
57 | * @return float |
||
58 | */ |
||
59 | public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): float |
||
65 | |||
66 | /** |
||
67 | * Calculates a destination point for the given point, bearing angle, |
||
68 | * and distance. |
||
69 | * |
||
70 | * @param Coordinate $point |
||
71 | * @param float $bearing the bearing angle between 0 and 360 degrees |
||
72 | * @param float $distance the distance to the destination point in meters |
||
73 | * |
||
74 | * @return Coordinate |
||
75 | * @throws InvalidArgumentException |
||
76 | */ |
||
77 | public function calculateDestination(Coordinate $point, float $bearing, float $distance): Coordinate |
||
89 | } |
||
90 |