public void InexactDistances(double[] distances) { Point beacon1 = new Point(10.0, 10.0, 10.0); Point beacon2 = new Point(0.0, 0.0, 0.0); Point beacon3 = new Point(10.0, 0.0, 0.0); Point beacon4 = new Point(0.0, 10.0, 0.0); Point searchPoint = new Point(5.0, 5.0, 5.0); List <Point> points = new List <Point>(); points.Add(beacon1); points.Add(beacon2); points.Add(beacon3); points.Add(beacon4); TrilaterationFunction tf = new TrilaterationFunction(); Point calculatedPoint = tf.CalculatePosition(points, distances); double [] calculatedDistances = tf.CalculateDistances(points, calculatedPoint); double [] residuals = tf.CalculateResiduals(distances, calculatedDistances); double [] fixedDistances = tf.GetFixedDistances(distances, calculatedDistances); int maxIterations = 10; int i = 0; while (i++ < maxIterations) { calculatedDistances = tf.CalculateDistances(points, calculatedPoint); residuals = tf.CalculateResiduals(distances, calculatedDistances); fixedDistances = tf.GetFixedDistances(distances, calculatedDistances); calculatedPoint = tf.CalculatePosition(points, fixedDistances); } Assert.Equal <Point>(searchPoint, calculatedPoint); }
public static void GetDistances() { Point beacon1 = new Point(10.0, 10.0, 10.0); Point beacon2 = new Point(0.0, 0.0, 0.0); Point beacon3 = new Point(10.0, 0.0, 0.0); Point beacon4 = new Point(0.0, 10.0, 0.0); List <Point> points = new List <Point>(); points.Add(beacon1); points.Add(beacon2); points.Add(beacon3); points.Add(beacon4); Point searchPoint = new Point(5.0, 5.0, 5.0); TrilaterationFunction tf = new TrilaterationFunction(); double[] d = tf.CalculateDistances(points, searchPoint); System.Console.WriteLine($"{d[0]} {d[1]} {d[2]} {d[3]}"); }
public void ExactPositionTestFullPoints() { Point beacon1 = new Point(10.0, 10.0, 10.0); Point beacon2 = new Point(0.0, 0.0, 0.0); Point beacon3 = new Point(10.0, 0.0, 0.0); Point beacon4 = new Point(0.0, 10.0, 0.0); Point searchPoint = new Point(5.0, 5.0, 5.0); List <Point> points = new List <Point>(); points.Add(beacon1); points.Add(beacon2); points.Add(beacon3); points.Add(beacon4); TrilaterationFunction tf = new TrilaterationFunction(); double [] distances = tf.CalculateDistances(points, searchPoint); Point calculatedPoint = tf.CalculatePosition(points, distances); Assert.Equal <Point>(searchPoint, calculatedPoint); }