我有N个点。每个点具有X和Y坐标。
I have N points. Each point has X and Y coordinates.
我需要找到这个点的质心的X和Y。你能给我一个算法来完成这个任务?
I need to find X and Y of center of mass this points. Can you give me an algorithm to accomplish this task?
有什么问题,只需取加权平均质量?
Is there something wrong with just taking the weighted average by mass?
for each point n
{
totalmass += n.mass
totalx += n.x*n.mass
totaly += n.y*n.mass
}
center = (totalx/totalmass,totaly/totalmass)
添加额外的尺寸合适。
add additional dimensions as appropriate.
上一篇:算法游戏币算法、游戏币
下一篇:包平方成长方形方形