一.质点系重心公式

x=(x1*m1+x2*m2+x3*m3.....xn*mn)/M  (M=m1+m2+m3+m4...+mn)

二.三角形重心

可直接求得,但在多边形剖分中 各三角形的质点的质量大小不一样 质量大小等于三角形面积.

三.多边形重心

三角形剖分+任意点的三角形剖分+三角形重心+质点系重心公式+任意点的三角形剖分

所以很容易知道一种很优美的计算公式(看代码)

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#define oo 0x13131313
#define maxn 1000000+10
using namespace std;
struct point{
double x,y;
};
point A[maxn];
int N;
double ansX,ansY;
double Sarea;
void input()
{
ansX=0;ansY=0;Sarea=0;
cin>>N;
for(int i=1;i<=N;i++)
{
scanf("%lf%lf",&A[i].x,&A[i].y);
}
}
void init()
{
freopen("a.in","r",stdin);
freopen("a.out","W",stdout);
}
void get_Sarea()
{
for(int i=1;i<=N;i++)
{
int j=i+1;
if(j==N+1) j=1;
Sarea+=(A[i].x*A[j].y-A[j].x*A[i].y)*0.5;
}
}
void get_ansXansY()
{
for(int i=1;i<=N;i++)
{
int j=i+1;
if(j==N+1) j=1;
double area=(A[i].x*A[j].y-A[j].x*A[i].y)*0.5;
ansX+=area*(A[i].x+A[j].x); // area*(A[i].x+A[j].x+0)/3 质点的重量
ansY+=area*(A[i].y+A[j].y);
}
ansX=ansX/(3*Sarea);
ansY=ansY/(3*Sarea);
}
int main()
{
int T;
cin>>T;
while(T--)
{
input();
get_Sarea();
get_ansXansY();
printf("%.2lf %.2lf\n",ansX,ansY);
}
return 0;
}

【计算几何初步:多边形中心】【HDU1115】Lifting the Stone的更多相关文章

  1. hdu1115 Lifting the Stone(几何,求多边形重心模板题)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...

  2. hdu 1115:Lifting the Stone(计算几何,求多边形重心。 过年好!)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  3. poj 1115 Lifting the Stone 计算多边形的中心

    Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  4. Lifting the Stone(hdu1115)多边形的重心

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...

  5. Lifting the Stone(求多边形的重心—)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...

  6. Lifting the Stone(多边形重心)

    Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. POJ 1385 Lifting the Stone (多边形的重心)

    Lifting the Stone 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/G Description There are ...

  8. hdu 1115 Lifting the Stone 多边形的重心

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. Lifting the Stone(hdoj1115)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  10. (hdu step 7.1.3)Lifting the Stone(求凸多边形的重心)

    题目: Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

随机推荐

  1. Rhythmbox乱码的解决的方法

    近期尝试 Listen 和 Banshee 才发现,Rhythmbox 上出现的 mp3乱码问题依然,并且更加严重,想要彻底弄清和解决必须搞清两点,第一, mp3 标签类型和编码,第二,各种播放器对 ...

  2. C#软件开发实例.私人订制自己的屏幕截图工具(七)加入放大镜的功能

    上一篇:C#软件开发实例.私人订制自己的屏幕截图工具(六)加入配置管理功能 因为截图时可能须要精确截取某一部分,所以须要放大镜的功能,这样截取的时候才更easy定位截图的位置. 加入PictureBo ...

  3. Ubuntu12.04 Git 服务器详细配置

    Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目,学过Linux的都知道,Git的优点我就不再多说了,我也是很喜欢Linux的.今天我们一起学习Git服务器在Ubunt ...

  4. 10. 混淆矩阵、总体分类精度、Kappa系数

    一.前言 表征分类精度的指标有很多,其中最常用的就是利用混淆矩阵.总体分类精度以及Kappa系数. 其中混淆矩阵能够很清楚的看到每个地物正确分类的个数以及被错分的类别和个数.但是,混淆矩阵并不能一眼就 ...

  5. 一篇文章讲清楚android ImageView.ScaleType

    2016-01-10 刚开始android编程的时候, 关于ImageView.ScaleType网络上好多, 说实话没看懂. 本文就是为了讲清楚这个, 有用的话转走, 请注明原地址和作者. 典型的代 ...

  6. SQL server根据值搜表名和字段

    DECLARE @what varchar(800) SET @what='lll' --要搜索的字符串 DECLARE @sql varchar(8000) DECLARE TableCursor ...

  7. WCF入门教程系列三

    一.WCF服务应用程序与WCF服务库 我们在平时开发的过程中常用的项目类型有“WCF 服务应用程序”和“WCF服务库”. WCF服务应用程序,是一个可以执行的程序,它有独立的进程,WCF服务类契约的定 ...

  8. (原)Windows下编译指纹识别的Rel_4.1.0库

    网址:http://www.cnblogs.com/darkknightzh/p/4867372.html.未经允许,严禁转载. 没怎么用过linux,对于MSYS和MinGW也基本没用过,因而编译R ...

  9. 【Lucene4.8教程之五】Luke

    一.Luke基本内容 1.Luke简介 Luke可用于查看Lucene创建的索引,并对其进行基本操作. 2.创建Luke (1)从Github上下载源文件 https://github.com/tar ...

  10. python运维开发(十六)----Dom&&jQuery

    内容目录: Dom 查找 操作 事件 jQuery 查找 筛选 操作 事件 扩展 Dom 文档对象模型(Document Object Model,DOM)是一种用于HTML和XML文档的编程接口.它 ...