hotrush/angular-sweep
Composer 安装命令:
composer require hotrush/angular-sweep
包简介
README 文档
README
PHP implementation of angular sweep algorithm
Solves issue of finding maximum points that can be enclosed in a circle of given radius and getting the center of this point.
https://en.wikipedia.org/wiki/Visibility_polygon#Angular_sweep
https://www.geeksforgeeks.org/angular-sweep-maximum-points-can-enclosed-circle-given-radius/
https://github.com/pear/Math_Complex/blob/master/Math/Complex.php
Installation
composer require hotrush/angular-sweep
Usage
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'
Testing
phpunit
FYI
https://www.geeksforgeeks.org/find-minimum-radius-atleast-k-point-lie-inside-circle/
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-09