computeInitialGuess method

  1. @override
Vector computeInitialGuess(
  1. List<Beacon> beacons
)
override

Implementation

@override
Vector computeInitialGuess(List<Beacon> beacons) {
  assert(beacons.length >= 3);

  Vector posA = beacons[0].position.toVector();
  Vector posB = beacons[1].position.toVector();
  Vector posC = beacons[2].position.toVector();
  double distA = beacons[0].distanceToUser;
  double distB = beacons[1].distanceToUser;
  double distC = beacons[2].distanceToUser;

  Vector ab = posB - posA;
  Vector ac = posC - posA;
  Vector ex = (ab) / ab.norm();
  double i = ex.dot(ac);
  Vector ey = (ac - ex * i) / ((ac - ex * i).norm());
  double d = (ab).norm();
  double j = ey.dot(ac);
  double x = (pow(distA, 2) - pow(distB, 2) + pow(d, 2)) / (2 * d);
  double y =
      (pow(distA, 2) - pow(distC, 2) + pow(i, 2) + pow(j, 2)) / (2 * j) -
          i * x / j;

  return posA + ex * x + ey * y;
}