找到点质量中心 [英] Find the center of mass of points

查看:103
本文介绍了找到点质量中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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.

这篇关于找到点质量中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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