Exemple #1
0
 public function testInvertValue()
 {
     $angleObject = new Angle(10, Angle::MINUTES);
     $angleObject->setValue(10, Angle::DEGREES);
     $angleObject->invertValue();
     $angleValue = $angleObject->getValue(Angle::DEGREES);
     $this->assertEquals(-10.0, $angleValue);
 }
Exemple #2
0
 /**
  * Get the destination for a given initial bearing and distance along a great circle route
  *
  * @param     Angle                 $bearing      Initial bearing
  * @param     Distance              $distance     Distance to travel along the route
  * @param     ReferenceEllipsoid    $ellipsoid    If left blank, a default value of 6371009.0 metres will
  *                                                             be used for the Earth Mean Radius for the calculation;
  *                                                         If a reference ellipsoid is specified, the Authalic Radius for
  *                                                             that ellipsoid will be used.
  * @return    LatLong               The endpoint Lat/Long for a journey from this Lat/Long starting on a bearing
  *                                               of $bearing and travelling for $distance along a great circle route
  * @throws    Exception
  */
 public function getDestination(Angle $bearing, Distance $distance, ReferenceEllipsoid $ellipsoid = null)
 {
     if (!is_null($ellipsoid)) {
         $earthMeanRadius = $ellipsoid->getAuthalicRadius();
     } else {
         $earthMeanRadius = 6371009.0;
         // metres
     }
     $destinationLatitude = asin(sin($this->latitude->getValue(Angle::RADIANS)) * cos($distance->getValue() / $earthMeanRadius) + cos($this->latitude->getValue(Angle::RADIANS)) * sin($distance->getValue() / $earthMeanRadius) * cos($bearing->getValue(Angle::RADIANS)));
     $destinationLongitude = $this->longitude->getValue(Angle::RADIANS) + atan2(sin($bearing->getValue(Angle::RADIANS)) * sin($distance->getValue() / $earthMeanRadius) * cos($this->latitude->getValue(Angle::RADIANS)), cos($distance->getValue() / $earthMeanRadius) - sin($this->latitude->getValue(Angle::RADIANS)) * sin($destinationLatitude));
     return new LatLong(new LatLong\CoordinateValues(self::cleanLatitude($destinationLatitude), self::cleanLongitude($destinationLongitude), Angle::RADIANS));
 }