PHP code example of hotrush / angular-sweep
1. Go to this page and download the library: Download hotrush/angular-sweep library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hotrush / angular-sweep example snippets
use Hotrush\AngularSweep\NumbersCollection;
use Hotrush\AngularSweep\ComplexNumber;
use Hotrush\AngularSweep\AngularSweep;
$coordinates = [
[6.47634, 7.69628],
[5.16828, 4.79915],
[6.69533, 6.20378],
];
$collection = new NumbersCollection();
foreach ($coordinates as $coordinate) {
$collection->add(new ComplexNumber($coordinate[0], $coordinate[1]));
}
$radius = 1;
$sweep = new AngularSweep($collection, $radius);
echo $sweep->getMax();
// 2
$center = $sweep->getMaxCenter();
echo $center->getReal() . '-' . $center->getIm();
// '6.47634-7.69628'