How to calculate 2D Trilateration Step by Step

In summary, the conversation discusses the concept of Trilateration and the math behind it. The speaker has provided coordinates for P1, P2, and P3 and is trying to find the distance from each point to an unknown point X. They have attempted to calculate the unit vectors and signed magnitudes, but are still unsure of how to continue. Another person suggests a straightforward approach using equations, but the speaker argues that it will not work. They then mention a paper outlining a trilateration algorithm using just three TDOA equations.
  • #1
Jose F Gomez D
6
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
  • #2
I have no idea what this method involves. However there is a straightforward approach as follows, with X=(x,y)
[itex]1)\ (x-10)^2+(y-10)^2=64[/itex] (distance to P1 squared)
[itex]2)\ (x-24)^2+(y-24)^2=100[/itex] (distance to P2 squared)
[itex]3)\ (x-23)^2+(y-19)^2=121[/itex] (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).
 
  • #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
 
  • #4
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.
 
  • #5
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
 
  • #6
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.
 
  • #7
OMG, I do not have ecuations, I have coordinates in an x y Cartesian map, p1 is located in 10,10
 
  • #8
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.
 
  • #9
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

1. How does trilateration work?

Trilateration is a mathematical technique used to determine the location of an object by using the distance between that object and three known reference points. These reference points are typically provided by GPS satellites or other radio signals. By calculating the intersection of three circles with their centers at the reference points and radii equal to the distance between the object and each reference point, the object's location can be determined.

2. What are the steps for performing 2D trilateration?

The steps for performing 2D trilateration are as follows:

  1. Collect the coordinates of the three reference points.
  2. Measure the distance between the object and each reference point.
  3. Using the coordinates and distances, set up a system of equations to solve for the x and y coordinates of the object's location.
  4. Solve the system of equations using a method such as substitution or elimination.
  5. The resulting solution will be the x and y coordinates of the object's location.

3. What are the limitations of 2D trilateration?

2D trilateration can be affected by errors in measurement, as well as obstacles or interference that can disrupt the signals from the reference points. Additionally, trilateration assumes that the reference points are fixed and known, which may not always be the case in real-world situations.

4. Can 2D trilateration be used for indoor positioning?

Yes, 2D trilateration can be used for indoor positioning as long as there are enough reference points with known coordinates and the necessary distance measurements can be obtained. However, the accuracy may be affected by obstacles and interference in indoor environments.

5. How is 2D trilateration different from 3D trilateration?

The main difference between 2D and 3D trilateration is the number of dimensions used to determine the object's location. 2D trilateration uses two dimensions (x and y coordinates) while 3D trilateration uses three dimensions (x, y, and z coordinates). This means that 3D trilateration is better suited for pinpointing the location of an object in three-dimensional space, while 2D trilateration may be more appropriate for simpler two-dimensional positioning tasks.

Similar threads

  • General Math
Replies
24
Views
2K
Replies
7
Views
817
  • Advanced Physics Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
2
Replies
41
Views
4K
  • Introductory Physics Homework Help
Replies
2
Views
5K
  • Advanced Physics Homework Help
Replies
4
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
1K
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
25
Views
4K
Back
Top