# iBeacon trilateration

Discussion in 'iOS 7' started by moonman239, Sep 19, 2013.

1. ### moonman239 macrumors 68000

Joined:
Mar 27, 2009
#1
Does anyone know if apps that support iBeacon will be able to calculate my location using trilateration? If I worked on sites as large as malls or airports, and I wanted to use iBeacons, I'd probably want to use as few of them as reasonably possible. (Trilateration is where a device estimates its location based on its estimated distance to three or more points.)

2. ### moonman239 thread starter macrumors 68000

Joined:
Mar 27, 2009
#2
Update: I just looked at Apple's own documentation and learned that the location manager reports the distance to every beacon a user's device sees. Therefore, an app can estimate the user's position, but the app has to do the math.

All the app has to do is solve a 3-dimensional system of equations that are written like this:

(x - xbeacon)^2 + (y - ybeacon)^2 + (z - zbeacon)^2 = d^2

where z represents height above a chosen reference point. This reference point needs to be the same in all three equations.

Note: Use of 4 or more beacons will provide greater accuracy.

3. ### Duncan C macrumors 6502a

Joined:
Jan 21, 2008
Location:
Northern Virginia
#3

Righto. There's a good wiki article about trilateration. For typical ground-level applications you can simplify the problem by ignoring the z term entirely. (pretending the phone and all 3 beacons are on the same z coordinate.)

I haven't tackled this yet, but solving the 3 equations requires putting one of your beacons at 0,0, and expressing the positions of the second beacon as only and x offset from the first beacon, and of the third beacon as an x and y offset from the first beacon.

To do THAT, you have to shift and rotate your coordinate system, so the math gets kind of gnarly.

You have to first apply a transformation matrix to the coordinates of your beacons, solve the system of equations, and then apply the inverse of the transformation matrix to convert your coordinates back from your transformed coordinates to actual coordinates.

You could probably use the math libraries in GLKit (specifically those for manipulating GLKMatrix3) to do your transformations.