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

1k views Asked by At

I have a set of 'N' tags and their Euclidean distances. How do I plot this information on a 2D plane?

For 3 tags, the plot is a triangle where each corner is a tag.

I'm looking for an approximate algorithm to plot more than 3 tags on to X-Y plane which is indicative of the actual distances.

I'm attaching a screenshot of a seven tag matrix with their Euclidean distances 7 tag matrix

2

There are 2 answers

2
MBo On

For every triplet of points A,B,C you need to solve equation system

(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. So you have some freedom in initial choice:

Assign (0,0) coordinates to the first point. Let's (BX, 0) are coordinates of the second point. Find BX, CX , CY. Note the quadratic equation gives two possible positions for CY - choose positive one.

Solve similar system for the next point D. To get right choice from two possible positions - check for distance 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

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
0
David Eisenstat On

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.