0

I am trying to figure out the (x,y) position of the s2 node from the given example.

[example nodes]1

With trilateration I was able to calculate the first node s1 position based on the fixed anchors. Now I am trying to calculate the s2 node possible coordinates, what I have is:

Coordinates of two points:

A2:{y:0,x:4}

S1:{y:2,x:2}

Distances:

A2-S2: 2

S1-S2: 2

A2-S1: 2

Is there a way to calculate the possible positions of the s2 node based on this data in JavaScript? This should work on any type of triangle.

Update:

I think I found a solution, I can threat the 2 known position as the centre of two circle and the distances to the unknown point as radius, than I have to calculate the intersection of the two circle to get the possible coordinates.

A JavaScript function that returns the x,y points of intersection between two circles?

Community
  • 1
  • 1
Laci
  • 1
  • 2
  • This is not possible knowing 2 points and all distances. How would you know which side of the line the 3rd point is on? – Nick is tired Dec 14 '16 at 21:42
  • Yes you are right it can be on two sides, but I know the ranges of the sensors and also which sensor can talk with the other. So if s2 would be on the other side I would know that It can talk with A1 as well. If I can get 2 possible coordinates to s2 I could decide which one is valid based on some rules. – Laci Dec 14 '16 at 21:49
  • 1
    That's also a trilateration problem. You seem to have a solution for that already. – Nico Schertler Dec 14 '16 at 23:51
  • Well I have solution to decide wheather the point I get can be acceptable or not, but I still do not have the formula to calculate the third point. – Laci Dec 15 '16 at 07:33

1 Answers1

0

You have two known points A and B, unknown point C and distances dAC and dBC (dAB is useless). So you can build equation system

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

and solve it for C.X and C.Y (there are possible two, one and zero solutions).

Note that it is worth to shift coordinates by (-A.X, -B.X) to get simpler equations and solution, then add (A.X, B.X) to the solution coordinates

MBo
  • 77,366
  • 5
  • 53
  • 86