/** * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position * of the finder patterns and estimated module size.</p> */ private static function computeDimension($topLeft, $topRight, $bottomLeft, $moduleSize) { $tltrCentersDimension = MathUtils::round(ResultPoint::distance($topLeft, $topRight) / $moduleSize); $tlblCentersDimension = MathUtils::round(ResultPoint::distance($topLeft, $bottomLeft) / $moduleSize); $dimension = ($tltrCentersDimension + $tlblCentersDimension) / 2 + 7; switch ($dimension & 0x3) { // mod 4 case 0: $dimension++; break; // 1? do nothing // 1? do nothing case 2: $dimension--; break; case 3: throw NotFoundException::getNotFoundInstance(); } return $dimension; }