看看这个库:https://github.com/lemmingapex/Trilateration https://github.com/lemmingapex/Trilateration
使用 Apache Commons Math 中的 Levenberg-Marquardt 算法。
例如..
进入三边测量测试.java https://github.com/lemmingapex/trilateration/blob/master/src/test/java/com/lemmingapex/trilateration/TrilaterationTest.java
你可以看到:
double[][] positions = new double[][] { { 1.0, 1.0 }, { 2.0, 1.0 } };
double[] distances = new double[] { 0.0, 1.0 };
TrilaterationFunction trilaterationFunction = new TrilaterationFunction(positions, distances);
NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(trilaterationFunction, new LevenbergMarquardtOptimizer());
double[] expectedPosition = new double[] { 1.0, 1.0 };
Optimum optimum = solver.solve();
testResults(expectedPosition, 0.0001, optimum);
但如果你看到 Objectivec 的例子https://github.com/RGADigital/indoor_navigation_iBeacons/blob/show-work/ios/Group5iBeacons/Debug/Managers/Location/NonLinear/NonLinear.mm https://github.com/RGADigital/indoor_navigation_iBeacons/blob/show-work/ios/Group5iBeacons/Debug/Managers/Location/NonLinear/NonLinear.mm您可以注意到,精度被用作评估参数,而不是距离。