Skip to content

Commit 13a13ec

Browse files
authored
Merge 30a2908 into c301b13
2 parents c301b13 + 30a2908 commit 13a13ec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Location/Utility/PerpendicularDistance.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,18 @@ public function getPerpendicularDistance(Coordinate $point, Line $line)
6060

6161
$length = sqrt($normalizedX * $normalizedX + $normalizedY * $normalizedY + $normalizedZ * $normalizedZ);
6262

63-
$normalizedX /= $length;
64-
$normalizedY /= $length;
65-
$normalizedZ /= $length;
63+
if ($length > 0) {
64+
$normalizedX /= $length;
65+
$normalizedY /= $length;
66+
$normalizedZ /= $length;
67+
}
6668

6769
$thetaPoint = $normalizedX * $pointX + $normalizedY * $pointY + $normalizedZ * $pointZ;
6870

6971
$length = sqrt($pointX * $pointX + $pointY * $pointY + $pointZ * $pointZ);
7072

71-
$thetaPoint /= $length;
73+
if ($length > 0)
74+
$thetaPoint /= $length;
7275

7376
$distance = abs((M_PI / 2) - acos($thetaPoint));
7477

0 commit comments

Comments
 (0)