简体   繁体   English

如何在XY平面上绘制标签之间的欧几里德距离

[英]How do I plot Euclidean distance between tags on X-Y Plane

I have a set of 'N' tags and their Euclidean distances. 我有一组'N'标签和他们的欧几里德距离。 How do I plot this information on a 2D plane? 如何在2D平面上绘制此信息?

For 3 tags, the plot is a triangle where each corner is a tag. 对于3个标签,该图是一个三角形,其中每个角都是一个标签。

I'm looking for an approximate algorithm to plot more than 3 tags on to XY plane which is indicative of the actual distances. 我正在寻找一种近似算法,在XY平面上绘制超过3个标签,这表示实际距离。

I'm attaching a screenshot of a seven tag matrix with their Euclidean distances 我附上了七个标签矩阵的屏幕截图及其欧几里德距离 7标签矩阵

For every triplet of points A,B,C you need to solve equation system 对于A,B,C点的每个三元组,您需要求解方程组

(B.X - A.X)^2 + (B.Y - A.Y)^2 = dAB^2
(C.X - A.X)^2 + (C.Y - A.Y)^2 = dAC^2
(B.X - C.X)^2 + (B.Y - C.Y)^2 = dBC^2

Note that there are 6 unknowns for 3 equations. 注意,3个方程有6个未知数。 So you have some freedom in initial choice: 所以你有一些初步选择的自由:

Assign (0,0) coordinates to the first point. 将(0,0)坐标分配给第一个点。 Let's (BX, 0) are coordinates of the second point. 设(BX,0)是第二点的坐标。 Find BX, CX , CY. 找到BX,CX,CY。 Note the quadratic equation gives two possible positions for CY - choose positive one. 注意,二次方程给出了CY的两个可能位置 - 选择正位置。

Solve similar system for the next point D. To get right choice from two possible positions - check for distance dAD. 为下一个点解决类似的系统D.从两个可能的位置做出正确的选择 - 检查距离dAD。

Repeat process for all next points. 对所有下一个点重复上述过程。

Example for 3 points with distances dAB=1, dBC=1, dCD=1, dDA=1, dAC=1.414, dBD=1.414 距离dAB=1, dBC=1, dCD=1, dDA=1, dAC=1.414, dBD=1.414 3个点示例

A = 0,0
B = 1,0
C = 1,1 (another variant 1,-1)
for D using B,C we can calculate (0,1) and (2,0) - using dAD we choose the first one

You can use a force-directed graph drawing algorithm. 您可以使用力导向图绘制算法。 In a nutshell, the idea is to start with a random layout, put a spring between every pair of nodes with an assigned distance that exerts force one way or the other depending on whether their current distance is too large, and then simulate this system to equilibrium. 简而言之,我们的想法是从一个随机布局开始,在每对节点之间放置一个弹簧,其中指定的距离会根据当前距离是否过大而以某种方式施加力,然后将此系统模拟为平衡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM