Permalink
Browse files

Now checks for equal latitude before computing gradient (#95)

  • Loading branch information...
stevendesu authored and Nyholm committed Sep 16, 2017
1 parent d636167 commit 511dbef11d96dd1d9fdd54aa048694de739368ca
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/Vertex/Vertex.php
View
@@ -52,8 +52,14 @@ public function setFrom(CoordinateInterface $from)
return $this;
}
$this->gradient = ($this->to->getLongitude() - $this->from->getLongitude()) / ($this->to->getLatitude() - $this->from->getLatitude());
$this->ordinateIntercept = $this->from->getLongitude() - $this->from->getLatitude() * $this->gradient;
if ($this->to->getLatitude() !== $this->from->getLatitude()) {
$this->gradient = ($this->to->getLongitude() - $this->from->getLongitude()) / ($this->to->getLatitude() - $this->from->getLatitude());
$this->ordinateIntercept = $this->from->getLongitude() - $this->from->getLatitude() * $this->gradient;
} else {
$this->gradient = null;
$this->ordinateIntercept = null;
}
return $this;
}
@@ -76,8 +82,13 @@ public function setTo(CoordinateInterface $to)
return $this;
}
$this->gradient = ($this->to->getLongitude() - $this->from->getLongitude()) / ($this->to->getLatitude() - $this->from->getLatitude());
$this->ordinateIntercept = $this->from->getLongitude() - $this->from->getLatitude() * $this->gradient;
if ($this->to->getLatitude() !== $this->from->getLatitude()) {
$this->gradient = ($this->to->getLongitude() - $this->from->getLongitude()) / ($this->to->getLatitude() - $this->from->getLatitude());
$this->ordinateIntercept = $this->from->getLongitude() - $this->from->getLatitude() * $this->gradient;
} else {
$this->gradient = null;
$this->ordinateIntercept = null;
}
return $this;
}

0 comments on commit 511dbef

Please sign in to comment.