百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

delaunator

> 编程语言
开源

一个极其快速的 JavaScript 库,用于 2D 点的 Delaunay 三角化

2.6K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个极其快速的 JavaScript 库,用于 2D 点的 Delaunay 三角化

Delaunator

一个极其快速且稳健的 JavaScript 库,用于对二维点进行 Delaunay 三角剖分。

  • 交互式演示
  • 数据结构指南

基于 Delaunator 的项目

  • d3-delaunay 用于 Voronoi 图、搜索、遍历和渲染(是 D3 的一部分)。
  • d3-geo-voronoi 用于球面上的 Delaunay 三角剖分和 Voronoi 图(例如用于地理位置)。

示例

javascript
const coords = [377,479,  453,434,  326,387,  444,359,  511,389,
                586,429,  470,315,  622,493,  627,367,  570,314];
const delaunay = new Delaunator(coords);
console.log(delaunay.triangles);
// [4,3,1,  4,6,3,  1,5,4,  4,9,6,  2,0,1,  1,7,5,
//  5,9,4,  6,2,3,  3,2,1,  5,8,9,  0,7,1,  5,7,8]

安装

使用 NPM(npm install delaunator)或 Yarn(yarn add delaunator)安装,然后作为 ES 模块导入:

javascript
import Delaunator from 'delaunator';

要在浏览器中作为模块使用:

xml
<script type="module">
    import Delaunator from 'https://cdn.skypack.dev/[email protected]';
</script>

或者使用浏览器 UMD 构建版本,它会暴露一个 Delaunator 全局变量:

xml
<script src="https://unpkg.com/[email protected]/delaunator.min.js"></script>

API 参考

new Delaunator(coords)

根据点坐标数组构造德劳内三角剖分对象,坐标数组格式为: [x0, y0, x1, y1, ...](使用类型化数组可获得最佳性能)。

Delaunator.from(points[, getX, getY])

根据点数组(默认为 [x, y])构造德劳内三角剖分对象。 getX 和 getY 是可选函数,形式为 (point) => value,用于自定义点格式。 重复的点会被跳过。

delaunay.triangles

一个 Uint32Array 数组,包含三角形顶点索引(每三个数字组成一个三角形)。 所有三角形均为逆时针方向。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript2dalgorithmcomputational-geometrydelaunay

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言