* @zh 计算多边形中心 * @en Calculate polygon center
(vertices: readonly IPoint[])
| 247 | * @en Calculate polygon center |
| 248 | */ |
| 249 | private calculateCenter(vertices: readonly IPoint[]): IPoint { |
| 250 | let x = 0; |
| 251 | let y = 0; |
| 252 | |
| 253 | for (const v of vertices) { |
| 254 | x += v.x; |
| 255 | y += v.y; |
| 256 | } |
| 257 | |
| 258 | return createPoint(x / vertices.length, y / vertices.length); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * @zh 查找包含点的多边形 |
no test coverage detected