A How to calculate 2D Trilateration Step by Step

  • A
  • Thread starter Thread starter Jose F Gomez D
  • Start date Start date
  • Tags Tags
    2d Triangulation
AI Thread Summary
The discussion focuses on the challenges of implementing 2D trilateration using given reference points and distances. The user expresses confusion over the mathematical calculations required for determining the coordinates of an unknown point based on distances from three known points. It is highlighted that the distances provided violate the triangle inequality, indicating that no solution exists for the specified distances from the reference points. Participants suggest using graphical methods to visualize the problem and confirm the absence of a solution. The conversation emphasizes the importance of ensuring that the distances meet the necessary geometric conditions for trilateration to be valid.
Jose F Gomez D
Messages
6
Reaction score
0
I am trying to code Trilateration but I am not familiar with the math behind it. even though there is an explanation on Wikipedia in this link https://en.wikipedia.org/wiki/Trilateration
and a almost better explanation in here https://stackoverflow.com/questions/9747227/2d-trilateration?answertab=active#tab-top I am still confused on how to do it

I have P1, P2 and P3 as my reference points, and X as the point to find
and I want the distance from P1 to X = 8, P2 to X = 10 and P3 to X = 11

P1 (10,10)

P2 (24,24)

P3 (23,19)

so I have to calculate the unit vector in the direction from P1 to P2, following the formula ex = (P2 - P1) / ‖P2 - P1‖ meaning

ex,x = (P2x - P1x) / sqrt((P2x - P1x)^2 + (P2y - P1y)^2)

ex,y = (P2y - P1y) / sqrt((P2x - P1x)^2 + (P2y - P1y)^2)

ex,x = (24 - 10) / sqrt((24 - 10)^2 + (24 - 10)^2) = 14/sqrt(14^2+14^2) = 14/sqrt(392) = 14/20 = 0.7

ex,y = (24 - 10) / sqrt((24 - 10)^2 + (24 - 10)^2) = 14/sqrt(14^2+14^2) = 14/sqrt(392) = 14/20 = 0.7

then calculating the signed magnitude of the x component of the vector from P1 to P3 by i = ex(P3 - P1)

ix = 0.7*(23-10) = 0.7*13 = 9.1

iy = 0.7*(19-10) = 0.7*9 = 6.3

now calculating the the unit vector in the y direction from the formula
ey = (P3 - P1 - i*ex) / ‖P3 - P1 - i*ex‖**but here how do I continue?**I am assuming to continue like this

ey,y = (P3y - P1y - iy*ex,y) / sqrt((P3x - P1x - ix*ex,x)^2+(P3y - P1y - iy*ex,y)^2)

ey,x = (P3x - P1x - ix*ex,x) / sqrt((P3x - P1x - ix*ex,x)^2+(P3y - P1y - iy*ex,y)^2)

ey,y = (19 - 10 - 6.3*0.7) / sqrt((23 - 10 - 9.1*0.7)^2+(19 - 10 - 6.3*0.7)^2)

ey,x = (23 - 10 - 9.1*0.7) / sqrt((23 - 10 - 9.1*0.7)^2+(19 - 10 - 6.3*0.7)^2)

ey,y = 0.6

ey,x = 0.8

then the distance between the centers P1 and P2 is ‖P2 - P1‖

d = ‖P2 - P1‖ = sqrt((P2x - P1x)^2 + (P2y - P1y)^2) = 20

then the signed magnitude of the y component from j = ey(P3 - P1)

jxx = 0.6*(23-10) = 0.6*13 = 7.8

jxy = 0.8*(23-10) = 0.8*13 = 10.4jyx = 0.6*(19-10) = 0.6*9 = 5.4

jyy = 0.8*(19-10) = 0.8*9 = 7.2

then finally from https://stackoverflow.com/questions/9747227/2d-trilateration?answertab=active#tab-top

x = (r12 - r22 + d2) / 2d

y = (r12 - r32 + i2 + j2) / 2j - ix / jx = (8^2 - 10^2 + d^2) / 2*d = (8^2 - 10^2 + 20^2) / (2*20) = 9.1

y = (8^2 - 11^2 + i^2 + j^2) / (2*j - (ix / j))

**What do I do?**

please help
 
Mathematics news on Phys.org
I have no idea what this method involves. However there is a straightforward approach as follows, with X=(x,y)
1)\ (x-10)^2+(y-10)^2=64 (distance to P1 squared)
2)\ (x-24)^2+(y-24)^2=100 (distance to P2 squared)
3)\ (x-23)^2+(y-19)^2=121 (distance to P3 squared)
Combine equations: 1) minus 3) to get 4), 2) minus 3) to get 5). 4) and 5) are linear in x and y. Solve and check to see if they satisfy 1), 2), and 3).
 
nop it does not work in this way

P1 = x^2-20x+100+y^2-20y+100=64

P1 = x^2-20x+y^2-20y=-136P2 = x^2-48x+576+y^2-48y+576=100

P2 = x^2-48x+y^2-48y=-1052P3 = x^2-46x+529+y^2-38y+361=121

P3 = x^2-46x+y^2-38y=-769P4=P1-P3(x^2-20x+y^2-20y=-136)-( x^2-46x+y^2-38y=-769)

(x^2-20x+y^2-20y)-( x^2-46x+y^2-38y)=633

P4 = (26x+18y)=633P5=P2-P3(x^2-48x+y^2-48y=-1052)-( x^2-46x+y^2-38y=-769)

(x^2-48x+y^2-48y)-( x^2-46x+y^2-38y)=-283

(-2x-10y)=-283

P5 = (2x+10y)=283Substitution

(26x+18y)=633 y=(633-26x)/18

(2x+10y)=283 (2x+10((633-26x)/18))=283

(2x+((6330-260x)/18))=283 36x+6330-260x=283*18

6330-224x=5094 1236=224x

x= 5.52
y=(633-26(5.52))/18= 27.2
replacing x and y on P1,2,3

x^2-20x+y^2-20y=-136
〖5.52〗^2-20*5.52+〖27.2〗^2-20*27.2=315.91
wrong

x^2-48x+y^2-48y=-1052
〖5.52〗^2-48*5.52+〖27.2〗^2-48*27.2=351.75
wrong

x^2-46x+y^2-38y=-769
〖5.52〗^2-46*5.52+〖27.2〗^2-38*27.2=372.79
wrong
 
Jose F Gomez D said:
(x^2-20x+y^2-20y=-136)-( x^2-46x+y^2-38y=-769)
That is a really strange way of writing it.

The approach is right, if your result is wrong you did a mistake somewhere in between.
 
No, the calculation is right, x and y works with p4 and p5 but not with p1,2,3, it will never work I have checked online, this does not count, at the end I need trilateration not this
 
I checked the equations, your initial equations don't have a solution to start with.
Here are p1 and p2. The problem is easy to track down:
Jose F Gomez D said:
and I want the distance from P1 to X = 8, P2 to X = 10 and P3 to X = 11

P1 (10,10)

P2 (24,24)
P1 and P2 have a distance of 14*sqrt(2) > 18. There is no such point.
 
OMG, I do not have ecuations, I have coordinates in an x y Cartesian map, p1 is located in 10,10
 
Yes, and P2 is located at (24,24), that is 19.8 away from P1. There is no point that is 8 away from P1 and 10 away from P2, that would violate the triangle inequality.
 
Using graph paper and a compass, one can easily see if there is a solution. Place each point on the paper and use it a center of a circle with radius equal to the distance to the unknown point. If the three circles have a common point of intersection that is the solution. Otherwise (as in this case) there is none.
 
  • #10
Back
Top