Understanding what trilateration is, and how it is used to find people through social applications, doesn’t have to be difficult or overly complicated.  I’d like to attempt to share the concept with you, the reader, through a story.  A story of two guys looking for “love” on a small college campus…

Image of two guys sending text messages

Bill and Tim are looking for a quick hook-up between classes, so they hop onto their favorite “dating” app, Scrindrowlr.  After looking through the profiles of several different nearby guys Bill sees Tim’s profile, sends him a message, and they start chatting.  After a few minutes, Tim decides that Bill is amazing, “they’re soulmates”, and are meant to be together forever, but Bill thinks Tim seems “a little psycho”, and a “bit clingy” for somebody who barely knows him.  “Weird-ed out” by Tim, Bill decides to block him on the Scrindrowlr app and continue looking around for somebody taller, and maybe “a pinch less crazy”.
Image of Tim getting blocked on the app


Tim, as it turns out, is in fact a codependent sociopath, and stalker, with a few freshman level computer science classes under his belt.  He decides that he will find Bill and make him love him no matter what!  But how will he do that?  Well, first things first:  Bill blocked Tim, preventing him from seeing his profile or sending him messages.  But, Tim knows how to fix this…he simply creates a new profile, with a fake picture and name, disguising himself and granting him access once again to Bill.


Image of Tim with a disguise on


Now that Tim has a new profile and access to all of the users’ profiles, he switches over to his laptop where he has already reverse engineered the Scrindrowlr app.  Ready for the next step in his plan:  He starts making requests directly to the Scrindrowlr app’s server, which responds back to him with the raw data (in json format) that is usually translated by the app into the beautiful layout of profiles you would normally see on your phone.

His first request to the server is for a list of guys that are nearby:
Image showing Scrindrowlr API response


The server replies with information like that shown above.  Notice that the application developers have learned from past mistakes and removed the actual latitude and longitude (GPS coordinates) of users from any of the server’s responses, but they’ve still left the distance fields (“dst”) populated, showing how far away each user is from Tim.  These distances are all that Tim needs to find “the love of his life”, Bill!

Seeing that the server is responding to him, Tim sends three more requests, changing his own GPS coordinates each time, to different predetermined positions nearby.  The first response from the server shows that Bill is 2 kilometers away from Tim’s current position.  So, Tim changes his GPS coordinates and requests a list of nearby guys again from the server, which this time puts Bill at 1.5 kilometers from his new position.  Things look promising so Tim chooses a third, and final, location a little farther away from the first and second ones.  He gets the data back from the Scrindrowlr server and sees that Bill is 3 kilometers from that location.

Tim now has the distance Bill is from three known points (GPS coordinates), but Bill could be located in any direction from those points.  At each point Tim uses, he can draw a circle around himself with a radius equal to the distance Bill is away from him, and he can be certain that Bill is located somewhere on that circle.


Different colored circles overlaid on a map


Assuming that Bill stayed in the same spot or close to it, while Tim’s position changed three times, he can assume that Bill will be located at the intersection of all three circles.  And he is!  But how does Tim know that?


Shows 3 colored lines intersecting on Bill's position


Trilateration is the method Tim uses once the distances from 3 known points have been found.  The math used to solve a trilateration problem involves converting GPS into ECEF coordinates based on a geodetic approximation of the Earth’s spherical radius, and then back to GPS coordinates; solving a system of equations; and understanding the Pythagorean Theorem, give or take some linear algebra and trigonometry.  But who needs that!  Tim simply plugs his information into a program he downloaded (or a web form), that somebody else wrote to solve these types of problems…and in less than a second it spits out Bill’s location!


shows Bill's Latitude and Longitude 40.794284 and -77.863401


To make sure the coordinates are correct, Tim sends one more request to the Scrindrowlr server.  If he has calculated Bill’s position correctly and sets his own position to the same place as Bill’s, then the server should report zero distance between them (or a few feet depending on how much Bill has moved).  He sends the data to the server, and it responds back that “User: Bill is 0 ft away”.  “Yipee! “, shouts Tim!  Now he can go visit Bill, in person, to explain to him why they belong together!


Bill and Tim images overlaid on eachother


Realizing that Bill may be gone by the time he gets there, Tim decides to write a small computer script that automatically makes requests to the Scrindrowlr server every 10 minutes.   His little PHP script uses the data returned from the server to calculate Bill’s location — which it confirms with a fourth request, and posts to a map on a webpage that Tim can access, on his phone, from anywhere.


Image of phone screen with Bill's path traced in green


Now Tim knows where Bill is all of the time (or anytime he is logged onto Scrindrowlr) — so he can bring him presents, or make sure he isn’t talking to anyone else that might spoil their “relationship”!  Either way, all that it took was a little bit of computer know-how, some basic web design skills, and Tim can now be wherever Bill is, all of the time! Oh “true love”.

— The End —


If you would like to try out trilateration yourself, check out the calculator I created.  It is a bit rough in design, but it should demonstrate that you don’t have to know much about trilateration to use it.

(hint: trilateration works best if you keep distances under 5 km, or even 1000 meters if you can.  This is due to the curvature of the Earth — a topic for a later post)