View Full Version : iBeacon trilateration

moonman239

Sep 19, 2013, 07:44 PM

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

moonman239

Sep 20, 2013, 01:53 PM

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.

Duncan C

Dec 5, 2013, 08:19 AM

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.

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.