getPoint2() public méthode

public getPoint2 ( ) : Coordinate
Résultat Coordinate
 /**
  * @param Coordinate $point
  * @param Line $line
  *
  * @return float
  */
 public function getPerpendicularDistance(Coordinate $point, Line $line)
 {
     $ellipsoid = $point->getEllipsoid();
     $ellipsoidRadius = $ellipsoid->getArithmeticMeanRadius();
     $firstLinePointLat = $this->deg2radLatitude($line->getPoint1()->getLat());
     $firstLinePointLng = $this->deg2radLongitude($line->getPoint1()->getLng());
     $firstLinePointX = $ellipsoidRadius * cos($firstLinePointLng) * sin($firstLinePointLat);
     $firstLinePointY = $ellipsoidRadius * sin($firstLinePointLng) * sin($firstLinePointLat);
     $firstLinePointZ = $ellipsoidRadius * cos($firstLinePointLat);
     $secondLinePointLat = $this->deg2radLatitude($line->getPoint2()->getLat());
     $secondLinePointLng = $this->deg2radLongitude($line->getPoint2()->getLng());
     $secondLinePointX = $ellipsoidRadius * cos($secondLinePointLng) * sin($secondLinePointLat);
     $secondLinePointY = $ellipsoidRadius * sin($secondLinePointLng) * sin($secondLinePointLat);
     $secondLinePointZ = $ellipsoidRadius * cos($secondLinePointLat);
     $pointLat = $this->deg2radLatitude($point->getLat());
     $pointLng = $this->deg2radLongitude($point->getLng());
     $pointX = $ellipsoidRadius * cos($pointLng) * sin($pointLat);
     $pointY = $ellipsoidRadius * sin($pointLng) * sin($pointLat);
     $pointZ = $ellipsoidRadius * cos($pointLat);
     $normalizedX = $firstLinePointY * $secondLinePointZ - $firstLinePointZ * $secondLinePointY;
     $normalizedY = $firstLinePointZ * $secondLinePointX - $firstLinePointX * $secondLinePointZ;
     $normalizedZ = $firstLinePointX * $secondLinePointY - $firstLinePointY * $secondLinePointX;
     $length = sqrt($normalizedX * $normalizedX + $normalizedY * $normalizedY + $normalizedZ * $normalizedZ);
     $normalizedX /= $length;
     $normalizedY /= $length;
     $normalizedZ /= $length;
     $thetaPoint = $normalizedX * $pointX + $normalizedY * $pointY + $normalizedZ * $pointZ;
     $length = sqrt($pointX * $pointX + $pointY * $pointY + $pointZ * $pointZ);
     $thetaPoint /= $length;
     $distance = abs(M_PI / 2 - acos($thetaPoint));
     return $distance * $ellipsoidRadius;
 }
Exemple #2
0
 public function testCreateLine()
 {
     $point1 = new Coordinate(52.5, 13.5);
     $point2 = new Coordinate(64.09999999999999, -21.9);
     $line = new Line($point1, $point2);
     $this->assertEquals($point1, $line->getPoint1());
     $this->assertEquals($point2, $line->getPoint2());
 }