2d-polygon-contains-polygon 中文文档教程
2d-plolygon-contains-polygon
测试一个多边形是否完全包含另一个多边形
,这在计算多边形是洞还是岛时很有用。
这个库没有高度优化,但应该适合您对一般情况的需求。 如果它不够快,请打我,我会看看我们能做些什么。
install
npm install 2d-plolygon-contains-polygon
use
var a = [
[0, 0],
[100, 0],
[100, 100],
[0, 100]
];
var b = [
[20, 20],
[80, 20],
[80, 80],
[20, 80]
];
console.log(contains(a, b));
// output: true
api surface
contains(container
, contained
)
容器
和 container
是由二维数组表示的多边形(即 [[x, y], [x, y], ]
)
返回 true
如果 contained
包含在 container
中,否则为 false
。
license
2d-plolygon-contains-polygon
test if a polygon completely contains another polygon
this can useful when computing whether or not a polygon is a hole or island.
This library is not highly optimized, but should suit your needs for the general case. Hit me up if it's not fast enough and I'll see what we can do.
install
npm install 2d-plolygon-contains-polygon
use
var a = [
[0, 0],
[100, 0],
[100, 100],
[0, 100]
];
var b = [
[20, 20],
[80, 20],
[80, 80],
[20, 80]
];
console.log(contains(a, b));
// output: true
api surface
contains(container
, contained
)
container
and container
are polygons represented by a 2d array (i.e. [[x, y], [x, y], ]
)
returns true
if contained
is contained in container
, and false
otherwise.