:octocat: there's areason why these methods were static...

This commit is contained in:
smiley
2024-07-21 15:59:26 +02:00
parent 7b1d9617d3
commit a792c9f27a
+5 -5
View File
@@ -41,14 +41,14 @@ final class FinderPattern extends ResultPoint{
* @return float distance between two points
*/
public function getDistance(FinderPattern $b):float{
return $this->distance($this->x, $this->y, $b->x, $b->y);
return self::distance($this->x, $this->y, $b->x, $b->y);
}
/**
* Get square of distance between a and b.
*/
public function getSquaredDistance(FinderPattern $b):float{
return $this->squaredDistance($this->x, $this->y, $b->x, $b->y);
return self::squaredDistance($this->x, $this->y, $b->x, $b->y);
}
/**
@@ -67,15 +67,15 @@ final class FinderPattern extends ResultPoint{
);
}
private function squaredDistance(float $aX, float $aY, float $bX, float $bY):float{
private static function squaredDistance(float $aX, float $aY, float $bX, float $bY):float{
$xDiff = ($aX - $bX);
$yDiff = ($aY - $bY);
return ($xDiff * $xDiff + $yDiff * $yDiff);
}
public function distance(float $aX, float $aY, float $bX, float $bY):float{
return sqrt($this->squaredDistance($aX, $aY, $bX, $bY));
public static function distance(float $aX, float $aY, float $bX, float $bY):float{
return sqrt(self::squaredDistance($aX, $aY, $bX, $bY));
}
}