mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-10 17:28:40 +00:00
52 lines
1.2 KiB
PHP
Executable File
52 lines
1.2 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Jingga
|
|
*
|
|
* PHP Version 8.1
|
|
*
|
|
* @package tests
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\tests\Math\Geometry\ConvexHull;
|
|
|
|
use phpOMS\Math\Geometry\ConvexHull\MonotoneChain;
|
|
|
|
/**
|
|
* @testdox phpOMS\tests\Math\Geometry\ConvexHull\MonotoneChainTest: Monotone chain
|
|
*
|
|
* @internal
|
|
*/
|
|
final class MonotoneChainTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* @testdox A convex hull can be formed from multiple points on a plane
|
|
* @covers \phpOMS\Math\Geometry\ConvexHull\MonotoneChain
|
|
* @group framework
|
|
*/
|
|
public function testMonotoneChain() : void
|
|
{
|
|
self::assertEquals([['x' => 9, 'y' => 0]], MonotoneChain::createConvexHull([['x' => 9, 'y' => 0]]));
|
|
|
|
$points = [];
|
|
for ($i = 0; $i < 10; ++$i) {
|
|
for ($j = 0; $j < 10; ++$j) {
|
|
$points[] = ['x' => $i, 'y' => $j];
|
|
}
|
|
}
|
|
|
|
self::assertEquals([
|
|
['x' => 0, 'y' => 0],
|
|
['x' => 9, 'y' => 0],
|
|
['x' => 9, 'y' => 9],
|
|
['x' => 0, 'y' => 9],
|
|
],
|
|
MonotoneChain::createConvexHull($points)
|
|
);
|
|
}
|
|
}
|