# 计算多边形切线点(polygonTangents)
> npm install @turf/polygon-tangents
Finds the tangents of a (Multi)Polygon from a Point.
接收一个点和一个(Multi)Polygon,计算二者的切线,返回切线在(Multi)Polygon 上的点
参数
参数 | 类型 | 描述 |
---|---|---|
pt | Coor | 参与计算的点 |
polygon | Feature<Polygon|MultiPolygon> | 参与计算的多边形 |
返回
FeatureCollection<Point> - Feature Collection containing the two tangent points
FeatureCollection<Point> - 包含两个切点的要素集合
示例
var polygon = turf.polygon([
[
[11, 0],
[22, 4],
[31, 0],
[31, 11],
[21, 15],
[11, 11],
[11, 0],
],
]);
var point = turf.point([61, 5]);
var tangents = turf.polygonTangents(point, polygon);
/*
{
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: {
type: "point",
coordinates: [21, 15]
},
properties: {}
},
{
type: "Feature",
geometry: {
type: "point",
coordinates: [31, 0]
},
properties: {}
}
]
}
*/
基础用法
Copy
动态绘制
Copy