There’s a game coming out called starbase that contains its own programming language. I’m trying to make a GPS system using at least 4 reference points. In the game there are receivers and transmitters that give distances. Essentially I have 4 known points with distances to a point. I know I can use trilateration but I can’t seem to find an actual equation that I can turn into code. If anyone can help that would be great :).
Asked
Active
Viewed 151 times
0
-
This seems to be a mathematical rather than programming question and as such it might be better suited for https://math.stackexchange.com/ . – Dominik Mokriš May 08 '20 at 09:24
-
It would also deserve to be a bit more precise. For instance, what sort of points are the inputs? Are they in 3D? 2D? On a surface of a sphere? The same goes for the output point. – Dominik Mokriš May 08 '20 at 09:24
-
Finally, have you read https://stackoverflow.com/help/how-to-ask ? Specifically, I am somehow missing what you have tried so far. What is this trilateration you mention and why doesn't is solve your problem? – Dominik Mokriš May 08 '20 at 09:25
2 Answers
1
You have equations like this for squared distance:
(Ax-x)^2 + (Ay-y)^2 + (Az-z)^2 = A_Dist^2 {1}
where Ax,Ay,Az are coordinates of the first receiver, unknowns x,y,z are object coordinates and A_Dist is distance from pbject to receiver A. Together with similar equations for two more recievers you have system of three equations with three unknowns. Clue to solve.

MBo
- 77,366
- 5
- 53
- 86
0
One way to approach this, is to start with a random point p (for example your last known position). And then:
- loop through each of the stations
- calculate the distance between p and the station
- if the distance is too large, step an epsilon towards the station
- if the distance is too small, step an epsilon away from the station
- this epsilon should be proportional to the magnitude of the difference
- repeat this either a fixed number of times, or until the position doesn't change much anymore
Such an approach allows for more than 4 stations and also for some measuring errors.
You can experiment with the size of epsilon and the number of steps to get good enough results in few iterations, depending on the needs.

JohanC
- 71,591
- 8
- 33
- 66