Project Compass: Trilateration
The following is a walk through of the mathematics used in the solution of the trilateration problem for Project Compass. It is provided for the amusement of those of you who might be interested in such esoteric workings and, more importantly, to allow those reviewing the project to check and critique its math, techniques, data analysis, and conclusions.
Set Up
We start with equations for 4 spheres, then expand them and solve with standard addition/multiplication of equations:
(x-xa)^2 + (y-ya)^2 + (z-za)^2 = da^2
(x-xb)^2 + (y-yb)^2 + (z-zb)^2 = db^2
(x-xc)^2 + (y-yc)^2 + (z-zc)^2 = dc^2
(x-xd)^2 + (y-yd)^2 + (z-zd)^2 = dd^2
where,
- (x, y, z) is the coordinate position of the star system being measured and is the unknown for which we are solving.
- (xa, ya, za) is the coordinate position of reference system A
- (xb, yb, zb) is the coordinate position of reference system B
- (xc, yc, zc) is the coordinate position of reference system C
- (xd, yd, zd) is the coordinate position of reference system D
- "da", is the measured distance from (x, y, z) to (xa, ya, za)
- "db", is the measured distance from (x, y, z) to (xb, yb, zb)
- "dc", is the measured distance from (x, y, z) to (xc, yc, zc)
- "dd", is the measured distance from (x, y, z) to (xd, yd, zd)
Work
Expansion:
(x^2 - 2xa*x + xa^2) + (y^2 - 2ya*y + ya^2) + (z^2 - 2za*z + za^2) = da^2
(x^2 - 2xb*x + xb^2) + (y^2 - 2yb*y + yb^2) + (z^2 - 2zb*z + zb^2) = db^2
(x^2 - 2xc*x + xc^2) + (y^2 - 2yc*y + yc^2) + (z^2 - 2zc*z + zc^2) = dc^2
(x^2 - 2xd*x + xd^2) + (y^2 - 2yd*y + yd^2) + (z^2 - 2zd*z + zd^2) = dd^2
(x^2 - 2xa*x + xa^2) + (y^2 - 2ya*y + ya^2) + (z^2 - 2za*z + za^2) = da*da
(x^2 - 2xb*x + xb^2) + (y^2 - 2yb*y + yb^2) + (z^2 - 2zb*z + zb^2) + (-x^2 + 2xa*x - xa^2) + (-y^2 + 2ya*y - ya^2) + (-z^2 + 2za*z - za^2) = db*db - da*da
(x^2 - 2xc*x + xc^2) + (y^2 - 2yc*y + yc^2) + (z^2 - 2zc*z + zc^2) + (-x^2 + 2xa*x - xa^2) + (-y^2 + 2ya*y - ya^2) + (-z^2 + 2za*z - za^2) = dc*dc - da*da
(x^2 - 2xd*x + xd^2) + (y^2 - 2yd*y + yd^2) + (z^2 - 2zd*z + zd^2) + (-x^2 + 2xa*x - xa^2) + (-y^2 + 2ya*y - ya^2) + (-z^2 + 2za*z - za^2) = dd*dd - da*da
Subtraction of first row from each subsequent row creates a 3x4 matrix of the last 3:
(x^2 - 2xa*x + xa^2) + (y^2 - 2ya*y + ya^2) + (z^2 - 2za*z + za^2) = da*da
(-2xb*x + xb*xb) + (-2yb*y + yb*yb) + (-2zb*z + zb*zb) + (2xa*x - xa*xa) + (2ya*y - ya*ya) + (2za*z - za*za) = db*db - da*da
(-2xc*x + xc*xc) + (-2yc*y + yc*yc) + (-2zc*z + zc*zc) + (2xa*x - xa*xa) + (2ya*y - ya*ya) + (2za*z - za*za) = dc*dc - da*da
(-2xd*x + xd*xd) + (-2yd*y + yd*yd) + (-2zd*z + zd*zd) + (2xa*x - xa*xa) + (2ya*y - ya*ya) + (2za*z - za*za) = dd*dd - da*da
Simplifying:
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
-2xb*x - 2yb*y - 2zb*z + 2xa*x + 2ya*y + 2za*z = db*db - da*da - xb*xb - yb*yb - zb*zb + xa*xa + ya*ya + za*za
-2xc*x - 2yc*y - 2zc*z + 2xa*x + 2ya*y + 2za*z = dc*dc - da*da - xc*xc - yc*yc - zc*zc + xa*xa + ya*ya + za*za
-2xd*x - 2yd*y - 2zd*z + 2xa*x + 2ya*y + 2za*z = dd*dd - da*da - xd*xd - yd*yd - zd*zd + xa*xa + ya*ya + za*za
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
2x*(xa - xb) + 2y*(ya - yb) + 2z*(za - zb) = db*db - da*da - xb*xb - yb*yb - zb*zb + xa*xa + ya*ya + za*za
2x*(xa - xc) + 2y*(ya - yc) + 2z*(za - zc) = dc*dc - da*da - xc*xc - yc*yc - zc*zc + xa*xa + ya*ya + za*za
2x*(xa - xd) + 2y*(ya - yd) + 2z*(za - zd) = dd*dd - da*da - xd*xd - yd*yd - zd*zd + xa*xa + ya*ya + za*za
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x*(xa - xb) + y*(ya - yb) + z*(za - zb) = (db*db - da*da - xb*xb - yb*yb - zb*zb + xa*xa + ya*ya + za*za)/2
x*(xa - xc) + y*(ya - yc) + z*(za - zc) = (dc*dc - da*da - xc*xc - yc*yc - zc*zc + xa*xa + ya*ya + za*za)/2
x*(xa - xd) + y*(ya - yd) + z*(za - zd) = (dd*dd - da*da - xd*xd - yd*yd - zd*zd + xa*xa + ya*ya + za*za)/2
Substitutions to simplify the math:
e = (db*db - da*da - xb*xb - yb*yb - zb*zb + xa*xa + ya*ya + za*za)/2
f = (dc*dc - da*da - xc*xc - yc*yc - zc*zc + xa*xa + ya*ya + za*za)/2
g = (dd*dd - da*da - xd*xd - yd*yd - zd*zd + xa*xa + ya*ya + za*za)/2
Solving the matrix:
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x*(xa - xb) + y*(ya - yb) + z*(za - zb) = e
x*(xa - xc) + y*(ya - yc) + z*(za - zc) = f
x*(xa - xd) + y*(ya - yd) + z*(za - zd) = g
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x + y*(ya - yb)/(xa - xb) + z*(za - zb)/(xa - xb) = e/(xa - xb)
x + y*(ya - yc)/(xa - xc) + z*(za - zc)/(xa - xc) = f/(xa - xc)
x + y*(ya - yd)/(xa - xd) + z*(za - zd)/(xa - xd) = g/(xa - xd)
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x + y*(ya - yb)/(xa - xb) + z*(za - zb)/(xa - xb) = e/(xa - xb)
0 + y*[ (ya - yc)/(xa - xc) - (ya - yb)/(xa - xb) ] + z*[ (za - zc)/(xa - xc) - (za - zb)/(xa - xb) ] = [ f/(xa - xc) - e/(xa - xb) ]
0 + y*[ (ya - yd)/(xa - xd) - (ya - yb)/(xa - xb) ] + z*[ (za - zd)/(xa - xd) - (za - zb)/(xa - xb) ] = [ g/(xa - xd) - e/(xa - xb) ]
More substitutions to simplify the math:
i = [ (ya - yc)/(xa - xc) - (ya - yb)/(xa - xb) ]
j = [ (za - zc)/(xa - xc) - (za - zb)/(xa - xb) ]
p = [ (ya - yd)/(xa - xd) - (ya - yb)/(xa - xb) ]
q = [ (za - zd)/(xa - xd) - (za - zb)/(xa - xb) ]
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x + y*(ya - yb)/(xa - xb) + z*(za - zb)/(xa - xb) = e/(xa - xb)
0 + y*i + z*j = [ f/(xa - xc) - e/(xa - xb) ]
0 + y*p + z*q = [ g/(xa - xd) - e/(xa - xb) ]
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x + y*(ya - yb)/(xa - xb) + z*(za - zb)/(xa - xb) = e/(xa - xb)
0 + y + z*j/i = [ f/(xa - xc) - e/(xa - xb) ]/i
0 + y + z*q/p = [ g/(xa - xd) - e/(xa - xb) ]/p
x*x - 2xa*x + y*y - 2ya*y + z*z - 2za*z = da*da - xa*xa - ya*ya - za*za
x + y*(ya - yb)/(xa - xb) + z*(za - zb)/(xa - xb) = e/(xa - xb)
0 + y + z*j/i = [ f/(xa - xc) - e/(xa - xb) ]/i
0 + 0 + z*(q/p - j/i) = { [ g/(xa - xd) - e/(xa - xb) ]/p - [ f/(xa - xc) - e/(xa - xb) ]/i }
Solution
These equations are sufficient to create spreadsheet formulas with x and y developing from the calculations of z:
z = { [ g/(xa - xd) - e/(xa - xb) ]/p - [ f/(xa - xc) - e/(xa - xb) ]/i }/(q/p - j/i)
y = [ f/(xa - xc) - e/(xa - xb) ]/i - z*j/i
x = e/(xa - xb) - y*(ya - yb)/(xa - xb) - z*(za - zb)/(xa - xb)
where again,
- (x, y, z) is the coordinate position of the star system being measured.
- (xa, ya, za) is the coordinate position of reference system A
- (xb, yb, zb) is the coordinate position of reference system B
- (xc, yc, zc) is the coordinate position of reference system C
- (xd, yd, zd) is the coordinate position of reference system D
- "da", is the measured distance from (x, y, z) to (xa, ya, za)
- "db", is the measured distance from (x, y, z) to (xb, yb, zb)
- "dc", is the measured distance from (x, y, z) to (xc, yc, zc)
- "dd", is the measured distance from (x, y, z) to (xd, yd, zd)
and
i = [ (ya - yc)/(xa - xc) - (ya - yb)/(xa - xb) ]
j = [ (za - zc)/(xa - xc) - (za - zb)/(xa - xb) ]
p = [ (ya - yd)/(xa - xd) - (ya - yb)/(xa - xb) ]
q = [ (za - zd)/(xa - xd) - (za - zb)/(xa - xb) ]
e = (db*db - da*da - xb*xb - yb*yb - zb*zb + xa*xa + ya*ya + za*za)/2
f = (dc*dc - da*da - xc*xc - yc*yc - zc*zc + xa*xa + ya*ya + za*za)/2
g = (dd*dd - da*da - xd*xd - yd*yd - zd*zd + xa*xa + ya*ya + za*za)/2