Prechádzať zdrojové kódy

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

smiley 1 rok pred
rodič
commit
a792c9f27a
1 zmenil súbory, kde vykonal 5 pridanie a 5 odobranie
  1. 5 5
      src/Detector/FinderPattern.php

+ 5 - 5
src/Detector/FinderPattern.php

@@ -41,14 +41,14 @@ final class FinderPattern extends ResultPoint{
 	 * @return float distance between two points
 	 * @return float distance between two points
 	 */
 	 */
 	public function getDistance(FinderPattern $b):float{
 	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.
 	 * Get square of distance between a and b.
 	 */
 	 */
 	public function getSquaredDistance(FinderPattern $b):float{
 	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);
 		$xDiff = ($aX - $bX);
 		$yDiff = ($aY - $bY);
 		$yDiff = ($aY - $bY);
 
 
 		return ($xDiff * $xDiff + $yDiff * $yDiff);
 		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));
 	}
 	}
 
 
 }
 }