# 鞋带公式

鞋带公式是一种数学算法，它根据简单多边形各顶点的笛卡尔坐标，沿边界依次求相邻顶点坐标的叉积之和，再取总和的绝对值的一半，从而算出该多边形的面积。<sup>[1](https://mathworld.wolfram.com/ShoelaceFormula.html)</sup> 它也被称为高斯面积公式、鞋带算法、鞋带法和测量师公式。<sup>[1](https://mathworld.wolfram.com/ShoelaceFormula.html)</sup> 这个名字来自把坐标写成两列时出现的交叉相乘图案，看上去像鞋带的系法。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup>

| 关键事实 | 细节 |
|---|---|
| 公式 | \( A = \tfrac{1}{2} \left| \sum_{i=1}^{n} (x_i y_{i+1} - x_{i+1} y_i) \right| \)，下标按模 \( n \) 取，使最后一个顶点绕回第一个<sup>[3](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)</sup> |
| 输入要求 | 至少 3 个顶点，按边界顺序（一致地顺时针或逆时针）列出，构成简单多边形<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup> |
| 有向面积 | 取绝对值之前的总和，在顶点为逆时针顺序时为正，顺时针顺序时为负，因此该公式同时给出面积和取向<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup> |
| 代价 | 对 \( n \) 个顶点的多边形为 \( O(n) \) 时间，计算方式是求与一个固定参考点构成的各带符号三角形面积之和<sup>[5](https://activities.tjhsst.edu/sct/lectures/2021/2021_03_26_Computational_Geometry.pdf)</sup> |
| 历史 | 由阿尔布雷希特·路德维希·弗里德里希·迈斯特于 1769 年发表；高斯在 1795 年使用过它，有一种说法把他的重新发现定在 1796 年<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup><sup> • </sup><sup>[6](https://mathyard.app/blog/shoelace-formula-polygon-areas)</sup> |
| 理论基础 | 公式的三角形形式是格林定理的一个特例<sup>[3](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)</sup> |
| 实际用途 | 测量学和林业中的土地面积计算；质心计算、多边形裁剪和网格处理的基础构件<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup><sup> • </sup><sup>[7](https://tamnd.github.io/brain/programming/algorithms/17/17.04/)</sup> |

## 公式

对于一个顶点为 \( (x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n) \) 并按边界顺序列出的多边形，其有向面积为<sup>[1](https://mathworld.wolfram.com/ShoelaceFormula.html)</sup>

\[ A = \tfrac{1}{2} \left( \begin{vmatrix} x_1 & x_2 \\ y_1 & y_2 \end{vmatrix} + \begin{vmatrix} x_2 & x_3 \\ y_2 & y_3 \end{vmatrix} + \cdots + \begin{vmatrix} x_n & x_1 \\ y_n & y_1 \end{vmatrix} \right), \]

其中每对竖线表示一个 2 乘 2 行列式。逐项写出来，就是<sup>[1](https://mathworld.wolfram.com/ShoelaceFormula.html)</sup>

\[ A = \tfrac{1}{2} \left( x_1 y_2 - x_2 y_1 + x_2 y_3 - x_3 y_2 + \cdots + x_n y_1 - x_1 y_n \right). \]

MathWorld 还给出一种简写形式：把 \( x \) 坐标叠在 \( y \) 坐标上方排成两长行，再对角交叉相乘。这种写法被说成是对行列式记号的滥用，但正是这种排列赋予了公式它的名字：对角乘积来回交叉，就像鞋上的鞋带左右交替交叉一样。<sup>[1](https://mathworld.wolfram.com/ShoelaceFormula.html)</sup>

真正的（无向）面积是有向和除以二的绝对值。符号本身在计算几何中很有用：有向面积为正，说明顶点是按逆时针列出的；为负，说明是顺时针；三个或更多互异点上的有向面积为零，说明这些点共线，或者没有按边界顺序排列。<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup><sup> • </sup><sup>[8](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)</sup>

## 为什么成立

每一项 \( \tfrac{1}{2}(x_i y_{i+1} - x_{i+1} y_i) \) 都是一个三角形的有向面积，这个三角形由取作原点的固定参考点与从顶点 \( i \) 到顶点 \( i+1 \) 的边构成。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup> 把所有边上的这些带符号三角形面积加起来，就得到多边形的面积。当参考点位于多边形之外时，有些三角形会覆盖多边形之外的地面；这些恰好是从参考点看去、其边按顺时针方向走过的三角形，它们计为负。多边形之外的每一处，被正三角形和负三角形覆盖的次数一样多，多出来的部分相互抵消，于是内部恰好被计算一次。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup>

第二条证明路线通过三角剖分。对一个三角形，可以用几何情形分析来验证公式，也可以用代数恒等式验证：一个三角形的有向面积可分解为相对一个固定点的三个有向三角形面积；然后，对任何更大的多边形，把任意一种三角剖分中各三角形的有向面积相加，涉及剖分内部对角线的项相互抵消。<sup>[3](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)</sup> 结果对逆时针多边形为正，对顺时针多边形为负。<sup>[3](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)</sup>

第三条路线使用向量微积分中的格林定理。取向量场 \( \vec{F} = (0, x) \)，其旋度为 1，格林定理把面积积分 \( \iint_R \mathrm{d}A \) 转换为沿边界的线积分 \( \oint_P x \, \mathrm{d}y \)；沿直边计算该积分，就重现了鞋带和。<sup>[9](https://ximera.osu.edu/undefined/calculusA2/greensTheorem/digInGreensTheoremAsAPlanimeter)</sup> 同一个积分 \( \tfrac{1}{2} \int (x \, \mathrm{d}y - y \, \mathrm{d}x) \) 沿一条直边计算，得到 \( \tfrac{1}{2}(x_1 y_2 - x_2 y_1) \)，即带符号的三角形面积。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup>

一种等价的梯形形式把相邻顶点之间的竖条相加，<sup>[10](https://ics.uci.edu/~eppstein/164/lecture1a.pdf)</sup>

\[ A = \sum_{i=0}^{n-1} \tfrac{1}{2} (x_{i+1} - x_i)(y_i + y_{i+1}), \]

边界向右移动的竖条给出正贡献，向左移动的给出负贡献。

## 历史

德国数学家阿尔布雷希特·路德维希·弗里德里希·迈斯特（1724—1788）于 1769 年发表了该公式，卡尔·弗里德里希·高斯在 1795 年使用过它；一种流行的说法把高斯在研究行列式时作出的重新发现定在 1796 年，当时他 19 岁。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup><sup> • </sup><sup>[6](https://mathyard.app/blog/shoelace-formula-polygon-areas)</sup> 该公式基于高斯和 C.G.J. 雅可比描述的梯形公式。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup> 在测量实践中，同样的计算长期以来被安排成双子午距（DMD）法：为导线测量的每一段累积一个子午距，再乘以该段的纬距；两者是同一套代数经过重新排列，在正确排序的闭合图形上总是吻合。<sup>[8](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)</sup>

几何思想比坐标公式更古老。1854 年的一种测量仪器通过让指针沿边界绕行一圈、同时让一个小轮滚动和滑动，来测量地图上任意形状的面积；它的读数乘以一条臂的长度，就给出面积，这是同一套边界积分原理的机械形式。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup>

## 性质与推广

**取向与有向面积。** 由于求和是沿边按顺序进行的，公式不需要对多边形做三角剖分，也从不辨认内部；行走的取向完成了记账。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup> 有向面积也与坐标原点所在的位置无关，因为只有坐标差才起作用，所以平移整个多边形不会改变面积。<sup>[8](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)</sup>

**非凸与自重叠多边形。** 该公式对任何简单多边形都成立，无论凸与否。<sup>[5](https://activities.tjhsst.edu/sct/lectures/2021/2021_03_26_Computational_Geometry.pdf)</sup> 对于自相交的边界，结果是有向区域的代数和，而不是普通面积。<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup> 迈斯特本人就用这个公式来定义任意多边形——甚至非简单多边形——的有向面积；所得的值与参考点无关，公式把平面上的每个区域按某个整数次数计数，这种赋值现在称为亚历山大的编号方式。<sup>[3](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)</sup>

**导出量。** 同样的叉积还能给出多边形的质心。对于有向面积非零的多边形，<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup>

\[ C_x = \frac{1}{6A} \sum_i (x_i + x_{i+1})(x_i y_{i+1} - x_{i+1} y_i), \qquad C_y = \frac{1}{6A} \sum_i (y_i + y_{i+1})(x_i y_{i+1} - x_{i+1} y_i), \]

这与各顶点的算术平均不同。鞋带和还可以作为更高级算法的基础构件，包括多边形裁剪和网格处理。<sup>[7](https://tamnd.github.io/brain/programming/algorithms/17/17.04/)</sup>

**数值实践。** 当坐标数值很大时，推荐的做法是在计算前从每个顶点减去一个参考点（例如质心），以保证数值稳定性。<sup>[4](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)</sup> 在测量工作中，完整坐标的叉积可能达到八位有效数字，而它们的差只有六位，因此应在整个求和过程中保持完整精度，最后只舍入一次；在相减之前对每个乘积舍入，可能使面积变动超过测量本身的不确定度。<sup>[8](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)</sup> 对于整数坐标，该公式保持精确算术。<sup>[7](https://tamnd.github.io/brain/programming/algorithms/17/17.04/)</sup>

**相关结果。** 在测量中，坐标法和 DMD 法被用作交叉校验：由于它们在代数上完全相同，任何不一致都表明坐标列表顺序错误、没有闭合，或者含有重复点。<sup>[8](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)</sup>

## 应用

该公式的传统用武之地是测量学，从角点坐标精确计算土地面积在那里至关重要，它也被用于林业。<sup>[2](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)</sup> 在工程中，它从面积扩展到质心和惯性矩等几何性质，并在 Python 工作流中用 NumPy、Shapely 和 Matplotlib 等库实现，用于真实世界形状的计算建模。<sup>[12](https://www.researchgate.net/publication/393188890_THE_SHOELACE_ALGORITHM_IN_ENGINEERING_PYTHON_APPLICATIONS_FOR_AREA_AND_INERTIAL_ANALYSIS)</sup> 在计算几何中，它是一个标准的基本构件，受人看重是因为它同时提供面积和取向，对凸多边形和非凸多边形都适用，而且以线性时间运行。<sup>[7](https://tamnd.github.io/brain/programming/algorithms/17/17.04/)</sup> 它也是课外数学教育中的常见内容，用来展示坐标几何在地理、物理和建筑问题中的实际运用。<sup>[13](https://www.fmo-journal.org/index.php/fmo/en/article/view/394)</sup>

## References

1. [Weisstein, Eric W. "Shoelace Formula." MathWorld--A Wolfram Resource](https://mathworld.wolfram.com/ShoelaceFormula.html)
2. ["An area measured by walking round it," Matpic](https://www.matpic.com/essays/an-area-measured-by-walking-round-it/)
3. [Jeff Erickson, "Winding Number," computational topology course notes, University of Illinois](https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/02-winding-number.html)
4. ["Polygon Area Calculator (Gauss Shoelace Formula)," CalcoI](https://calcoi.com/en/calculator/polygon-area-shoelace-calculator/)
5. ["Computational Geometry," Thomas Jefferson High School for Science and Technology lecture notes](https://activities.tjhsst.edu/sct/lectures/2021/2021_03_26_Computational_Geometry.pdf)
6. ["Lacing Up Polygon Areas: The Shoelace Formula," Mathyard](https://mathyard.app/blog/shoelace-formula-polygon-areas)
7. ["17.4 Polygon Area," tamnd/brain algorithm notes](https://tamnd.github.io/brain/programming/algorithms/17/17.04/)
8. ["Area by coordinates: the shoelace method and DMD," CogoKit](https://cogokit.app/guides/area-by-coordinates-shoelace-and-dmd/)
9. ["Green's Theorem as a planimeter," Ximera, Ohio State University](https://ximera.osu.edu/undefined/calculusA2/greensTheorem/digInGreensTheoremAsAPlanimeter)
10. [David Eppstein, "Shoelace formula for area," Computational Geometry lecture notes, UC Irvine](https://ics.uci.edu/~eppstein/164/lecture1a.pdf)
11. ["Properties of Polygons (Sides, Angles and Diagonals)," UTSA Department of Mathematics wiki](https://mathresearch.utsa.edu/wiki/index.php?title=Properties_of_Polygons_%28Sides%2C_Angles_and_Diagonals%29)
12. ["The Shoelace Algorithm in Engineering: Python Applications for Area and Inertial Analysis," ResearchGate](https://www.researchgate.net/publication/393188890_THE_SHOELACE_ALGORITHM_IN_ENGINEERING_PYTHON_APPLICATIONS_FOR_AREA_AND_INERTIAL_ANALYSIS)
13. [Brydun, V. and Brydun, A., "The Shoelace Formula in the Scope of Out-of-School Mathematical Education," Physical and Mathematical Education](https://www.fmo-journal.org/index.php/fmo/en/article/view/394)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 几何学与拓扑学 › Analytic and coordinate geometry

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/shoelace-formula

English original: https://www.edgepedia.org/shoelace-formula
