的boost ::几何:多边形的质心的计算 [英] Boost::geometry : calculation of the centroid of a polygon

查看:1008
本文介绍了的boost ::几何:多边形的质心的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用Boost的几何形状,多为操纵多边形;我用的是心内置方法(<一个href=\"http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/centroid/centroid_2.html\" rel=\"nofollow\">http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/centroid/centroid_2.html)计算我的多角形的几何(巴里)中心,但输出我的点的坐标(组成一个特定的多边形)(并与一些Python脚本分析它们的一侧)后,最近我意识到,质心坐标previous方法是给我不对应的多边形点的几何平均值。

I've been working with the Boost geometry, mostly for manipulating polygons; I was using the centroid built-in method (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/centroid/centroid_2.html) for calculating the geometric (bary) center of my polygons, but recently after outputting the coordinates of my points (composing a specific polygon) (and analyzing them on the side with some Python scripts) I realized that the centroid coordinates the previous method was giving me do not correspond to the geometric mean of the points of the polygon.

我在两个维度,并把它代入方程,我应该有:

I'm in two dimensions and putting it into equations, I should have:

x_centroid = \frac{1}{number of points composing the polygon} \sum{point i} x_i

和同为y坐标。现在我怀疑这可能与事实升压几何库不是只盯着多边形(其外环)的边缘点,但它当作填充物做的。

and the same for the y coordinates. I'm now suspecting that this could have to do with the fact that the boost geometry library is not just looking at the points on the edge of the polygon (its outer ring) but treating it as a filled object.

请问你们有一些经验在操纵这些功能呢?

Does any of you have some experience in manipulating these functions?

顺便说一句,我使用:

point my_center(0,0);
bg::centroid(my_polygon,my_center);

来计算质心。

感谢您。

推荐答案

在Boost.Geometry由Bashein和Detmer提出的算法[1]是默认用于地域几何图形的重心的计算。

In Boost.Geometry the algorithm proposed by Bashein and Detmer [1] is used by default for the calculation of a centroid of Areal Geometries.

的原因是简单平均法,其中许多紧密间隔的顶点被放置在多边形的一侧的情况下失败。

The reason is that the simple average method fails for a case where many closely spaced vertices are placed at one side of a Polygon.

[1]的杰拉德Bashein和Paul R. Detmer。的多边形的质心。图形宝石四,学术preSS,1994年,第3-6页

[1] Gerard Bashein and Paul R. Detmer. "Centroid of a Polygon". Graphics Gems IV, Academic Press, 1994, pp. 3–6

这篇关于的boost ::几何:多边形的质心的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆