# Trilateration

In geometry, **trilateration** is the process of determining absolute or relative locations of points by measurement of distances, using the geometry of circles, spheres or triangles.^{[1]}^{[2]}^{[3]}^{[4]}

In addition to its interest as a geometric problem, trilateration does have practical applications in surveying and navigation, including global positioning systems (GPS). In contrast to triangulation, it does not involve the measurement of angles.

In two-dimensional geometry, it is known that if a point lies on two circles, then the circle centers and the two radii provide sufficient information to narrow the possible locations down to two. Additional information may narrow the possibilities down to one unique location.

In three-dimensional geometry, when it is known that a point lies on the surfaces of three spheres, then the centers of the three spheres along with their radii provide sufficient information to narrow the possible locations down to no more than two (unless the centers lie on a straight line).

This article describes a method for determining the intersections of three sphere surfaces given the centers and radii of the three spheres.

## Derivation

The intersections of the surfaces of three spheres is found by formulating the equations for the three sphere surfaces and then solving the three equations for the three unknowns, *x*, *y*, and *z*. To simplify the calculations, the equations are formulated so that the centers of the spheres are on the *z* = 0 plane. Also, the formulation is such that one center is at the origin, and one other is on the *x*-axis. It is possible to formulate the equations in this manner since any three non-collinear points lie on a unique plane. After finding the solution, it can be transformed back to the original three dimensional Cartesian coordinate system.

We start with the equations for the three spheres:

*d* is the x coordinate of point P2. You have to subtract it from x to get the length of the base of the triangle between the intersection and r2 (*x*, *y*, *z* are coordinates, not lengths).

We need to find a point located at (*x*, *y*, *z*) that satisfies all three equations.

We need to use r1 and r2 to eliminate y and z from the equation and solve for *x*:

Assuming that the first two spheres intersect in more than one point, that is that

In this case, substituting the equation for *x* back into the equation for the first sphere produces the equation for a circle, the solution to the intersection of the first two spheres:

Substituting into the formula for the third sphere and solving for *y* there results:

Now that the *x*- and *y*-coordinates of the solution point are found, the formula can be rearranged for the first sphere to find the *z*-coordinate:

Now the solution to all three points *x*, *y* and *z* is found. Because *z* is expressed as the positive or negative square root, it is possible for there to be zero, one or two solutions to the problem.

This last part can be visualized as taking the circle found from intersecting the first and second sphere and intersecting that with the third sphere. If that circle falls entirely outside or inside of the sphere, *z* is equal to the square root of a negative number: no real solution exists. If that circle touches the sphere on exactly one point, *z* is equal to zero. If that circle touches the surface of the sphere at two points, then *z* is equal to plus or minus the square root of a positive number.

## Preliminary and final computations

The *Derivation* section pointed out that the coordinate system in which the sphere centers are designated must be such that

- all three centers are in the plane
*z*= 0, - the sphere center,
*P*1, is at the origin, and - the sphere center,
*P*2, is on the*x*-axis.

In general the problem will not be given in a form such that these requirements are met.

This problem can be overcome as described below where the points, *P*1, *P*2, and *P*3 are treated as vectors from the origin where indicated. *P*1, *P*2, and *P*3 are of course expressed in the original coordinate system.

- is the unit vector in the direction from
*P*1 to*P*2. - is the signed magnitude of the
*x*component, in the figure 1 coordinate system, of the vector from*P*1 to*P*3. - is the unit vector in the y direction. Note that the points
*P*1,*P*2, and*P*3 are all in the*z*= 0 plane of the figure 1 coordinate system.

The third basis unit vector is . Therefore,

- the distance between the centers
*P*1 and*P*2 and - is the signed magnitude of the y component, in the figure 1 coordinate system, of the vector from
*P*1 to*P*3.

Using and as computed above, solve for *x*, *y* and *z* as described in the *Derivation* section. Then

gives the points in the original coordinate system since and , the basis unit vectors, are expressed in the original coordinate system.

## See also

- Distance geometry problem, similar technique applied to molecules
- Euclidean distance
- Multilateration – position estimation using measurements of time difference of arrival at (or from) three or more sites.
- Resection (orientation)
- Triangulateration

## External links

- stackexchange.com, PHP / Python Implementation