math - 是否有一种已知的算法可以根据已知点之间的距离来获取 n 个未知点的相对位置?
问题描述
我在 3D 空间中有一组 10 个点。我拥有的唯一信息是从每个点到每个其他点的距离。
我可以任意设置一个点为(0,0,0),另一个为我的X轴(距离,0,0)。
现在,似乎我应该能够使用这两个已知点来定位 3D 空间中的所有其他点(相对于前两个点)。
我有足够的信息来做这件事吗?是否有我应该研究的现有算法?
解决方案
对于前三点,我可以:
//store first one as zero point
if (pos.id == 0)
{
pos.position = Eigen::Vector3d(0, 0, 0);
}
//store second as X axis
if (pos.id == 1)
{
pos.position = Eigen::Vector3d(<Distance from 1 to 2>, 0, 0);
}
//triangulate third from distances
if (pos.id == 2)
{
double c = //distance from 3 to 1
double b = //distance from 3 to 2
double a = //distance from 1 to 2
pos.position.x() = (c*c - b * b + a * a) / (2 * a);
pos.position.y() = std::sqrt(c*c - pos.position.x()*pos.position.x());
}
从这里开始的第三点代码
现在我可以按照评论中的建议,使用三个已知点对以下几点进行多点定位。
推荐阅读
- python - 将鼠标悬停在多轴上的一个点上时如何使标签出现?
- windows - 了解 Windows Server 容器和 Hyper-V 容器
- javascript - 如何将我的大型 HTML 代码转换为用于 .innerHTML 的字符串
- c++ - 如果类型对升压累加器无效,如何创建回退?
- node.js - 在 ionic + electron (5.0.0) 桌面应用程序中需要节点模块
- java - 在具有更多维度的java中存储数据的最佳方法?
- ios - SpriteKit 接触检测有轻微延迟
- javascript - Angular ngClass/ngIf 不重新呈现更改
- csv - 如何从 csv 文件中选择特定 ID?
- mysql - 如何在 node.js 的 mysql 包中设置 IF 条件