Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
92 lines
2.2 KiB
PHP
92 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Class FinderPattern
|
|
*
|
|
* @created 17.01.2021
|
|
* @author ZXing Authors
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
* @copyright 2021 Smiley
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
namespace chillerlan\QRCode\Detector;
|
|
|
|
use function sqrt;
|
|
|
|
/**
|
|
* Encapsulates a finder pattern, which are the three square patterns found in
|
|
* the corners of QR Codes. It also encapsulates a count of similar finder patterns,
|
|
* as a convenience to the finder's bookkeeping.
|
|
*
|
|
* @author Sean Owen
|
|
*/
|
|
final class FinderPattern extends ResultPoint{
|
|
|
|
private int $count;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function __construct(float $posX, float $posY, float $estimatedModuleSize, ?int $count = null){
|
|
parent::__construct($posX, $posY, $estimatedModuleSize);
|
|
|
|
$this->count = ($count ?? 1);
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function getCount():int{
|
|
return $this->count;
|
|
}
|
|
|
|
/**
|
|
* @param \chillerlan\QRCode\Detector\FinderPattern $b second pattern
|
|
*
|
|
* @return float distance between two points
|
|
*/
|
|
public function getDistance(FinderPattern $b):float{
|
|
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 self::squaredDistance($this->x, $this->y, $b->x, $b->y);
|
|
}
|
|
|
|
/**
|
|
* Combines this object's current estimate of a finder pattern position and module size
|
|
* with a new estimate. It returns a new FinderPattern containing a weighted average
|
|
* based on count.
|
|
*/
|
|
public function combineEstimate(float $i, float $j, float $newModuleSize):self{
|
|
$combinedCount = ($this->count + 1);
|
|
|
|
return new self(
|
|
($this->count * $this->x + $j) / $combinedCount,
|
|
($this->count * $this->y + $i) / $combinedCount,
|
|
($this->count * $this->estimatedModuleSize + $newModuleSize) / $combinedCount,
|
|
$combinedCount
|
|
);
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
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 static function distance(float $aX, float $aY, float $bX, float $bY):float{
|
|
return sqrt(self::squaredDistance($aX, $aY, $bX, $bY));
|
|
}
|
|
|
|
}
|