- #1

- 6

- 0

## Main Question or Discussion Point

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.4

jyx = 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 / j

x = (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

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.4

jyx = 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 / j

x = (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