Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot points using interrelated distances?

I have a dictionary of points:

dictDistances = {A:{B:1.23, C:3.56}, B:{A:1.23, C:2.38}, C:{A:3.56, B:2.38}}

And I would like to plot them without using the absolute values, i.e. using the values from the dictionary. I can draw that, but I don't understand, how to do that in Python.

***There are much more than 3 points, like 300, I've just added this dictionary in order to demonstrate the kind of information I have.

****My points (each of 3) may not or may satisfy the triangle inequality theorem

UPDATE

What it's going to look like, given points A, B, C, D, E, F and some distances of range from x:y between them:

enter image description here

On the image provided you can see sets of all distances, i.e:

AB AC AD AF AE
BA BC BD BF BE
CB CA CD CF CE
DB DC DA DF DE
EB EC ED EF EA
FB FC FD FA FE

UPDATE 2

Rays: Ray A:

enter image description here

Ray B:

enter image description here

Ray C:

enter image description here

And the same for the rays E,D,F. Then I need to verify/modify them somehow. That's what I don't understand how to do in Python. Though it is absolutely possible to draw.

like image 232
Anna-Lischen Avatar asked Nov 10 '22 01:11

Anna-Lischen


1 Answers

I believe what you need to do is:

  • generate a dictionary that pairs up the point, distance for each point. i.e.

Dict_comp[A] = set((B, 1.3), (C, 9.5), (D, 20.3)) etc...

  • force point A to be at the origin (0,0)
  • choose a direction for the first point you want to plot. For instance, I would plot B at (1.3, 0).
  • once you have those first 2 points plotted, determine the coordinates for each other point based on their relationship to the first 2.
    • with the dictionary existing with each point's distance from the others known, you would look up Dict_comp[C] and check the distance from existing points to get that info.

This example from matplotlib will help you with polar coordinates - you'll have r from each of two existing points, then you can figure out theta. I wouldn't ever use more than two existing points to locate a third, given this info.

like image 110
mauve Avatar answered Nov 14 '22 21:11

mauve