Programming 板


LINE

※ 引述《makiyolove (暴力熊)》之铭言: : 各位版友好: : 在一起)。现在我想要在这个不规则图形上找重心,但是找 google 了一下看到这个.. http://www.exaflop.org/docs/cgafaq/cga2.html 我还看完了,顺便帮你整理出重点: 一整个多边形的重心好似很难算, 但是一个三角形的重心很好算, 两个三角形的重心也很好算,三个三角型的重心也很好算, 四个也很好算…五个也…六个也…七个也…八格也路… 原来如此!我们只要把多边形三角化以後, 求所有三角形的重心的重心就好了! 报告完毕。 我人真好 QQ -- Subject 2.02: How can the centroid of a polygon be computed? The centroid (a.k.a. the center of mass, or center of gravity) of a polygon can be computed as the weighted sum of the centroids of a partition of the polygon into triangles. The centroid of a triangle is simply the average of its three vertices, i.e., it has coordinates (x1 + x2 + x3)/3 and (y1 + y2 + y3)/3. This suggests first triangulating the polygon, then forming a sum of the centroids of each triangle, weighted by the area of each triangle, the whole sum normalized by the total polygon area. This indeed works, but there is a simpler method: the triangulation need not be a partition, but rather can use positively and negatively oriented triangles (with positive and negative areas), as is used when computing the area of a polygon. This leads to a very simple algorithm for computing the centroid, based on a sum of triangle centroids weighted with their signed area. The triangles can be taken to be those formed by one fixed vertex v0 of the polygon, and the two endpoints of consecutive edges of the polygon: (v1,v2), (v2,v3), etc. The area of a triangle with vertices a, b, c is half of this expression: (b[X] - a[X]) * (c[Y] - a[Y]) - (c[X] - a[X]) * (b[Y] - a[Y]); Code available at ftp://grendel.csc.smith.edu/pub/code/centroid.c (3K). Reference: [Gems IV] pp.3-6; also includes code. -- To iterate is human, to recurse, divine. 递回只应天上有, 凡人该当用回圈.   L. Peter Deutsch --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.160.107.24
1F:推 tropical72:我没试过,不过有人说误差蛮大的123.195.164.115 10/10 01:27
2F:推 Fenikso:这方法是准的哪会有误差... 220.133.186.66 10/10 03:25
3F:推 LPH66:数值(浮点数)误差吧... 140.112.28.92 10/10 05:54
4F:推 Fenikso:可是整个演算法就一次整数除法 220.133.186.66 10/10 09:18
5F:→ Fenikso:其他都是整数的加减乘.. 220.133.186.66 10/10 09:18
6F:→ Fenikso:如果允许有理数运算的话完全是准的 220.133.186.66 10/10 09:19
7F:→ Fenikso:就算用double也不会差多少 220.133.186.66 10/10 09:19
8F:→ yoco315:我有问题(举手) 关於误差大的说明 118.160.107.24 10/10 23:32
9F:→ yoco315:有没有更详细的资料?或是推荐较准的方法? 118.160.107.24 10/10 23:32
10F:推 AmosYang:八格也路 XD 65.87.177.87 10/11 10:21
11F:推 denny61001:大家都好强喔>///< 我什麽都看不懂 124.218.7.236 10/11 19:11
12F:推 LouisXIV:我是不知道应该要多准才行,不过既然是 220.133.41.64 10/12 01:45
13F:→ LouisXIV:影像处理的话,其实把pixel坐标平均一 220.133.41.64 10/12 01:46
14F:→ LouisXIV:下就可以得到答案了!误差应该在一个 220.133.41.64 10/12 01:46
15F:→ LouisXIV:pixel以内,感觉上已经可以接受了! 220.133.41.64 10/12 01:46







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP