- 积分
- 31723
- 明经币
- 个
- 注册时间
- 2005-5-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2012-2-14 21:37:53
|
显示全部楼层
参考:
qjchen 写的 http://bbs.mjtd.com/forum.php?mo ... mp;page=1#pid504508
http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
其中的这个就是公式
Centroid of polygon
The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where [对于一个封闭的非自交的多边形,形心公式如下]
and where A is the polygon's signed area,
In these formulas, the vertices are assumed to be numbered in order of their occurrence along the polygon's perimeter, and the vertex ( xn , yn ) is assumed to be the same as ( x0 , y0 ). Note that if the points are numbered in clockwise order the area A, computed as above, will have a negative sign; but the centroid coordinates will be correct even in this case [注意,有可能计算出来的面积会是负数,但是形心的位置是不会错的]
假如需要代码的话,可以参考这里 http://stackoverflow.com/questio ... ntroid-of-a-polygon
gile和Evgeniy也曾经写过带弧线的多线的Lisp代码,不过方法要更加复杂了
假如还需要二次矩的计算的话,可以参考这里
http://paulbourke.net/geometry/polyarea/上面这个网站还有大量的几何图形知识,在http://paulbourke.net/geometry/
|
|