private void Window_Loaded(object sender, RoutedEventArgs e) { Room room = new Room(); Tracker tracker = new Tracker("kinect", new Point(10, 10), 225, 15); room.AddTracker(tracker); //double angle = 180.0; //double fov = 190; //room.AddDevice(new Device("one", new Point(5, 0), angle, fov)); //room.AddDevice(new Device("two", new Point(10, 0), angle, fov)); //room.AddDevice(new Device("three", new Point(15, 0), angle, fov)); //room.AddDevice(new Device("four", new Point(10, 5), angle, fov)); //room.AddDevice(new Device("five", new Point(10, -5), angle, fov)); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("one")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("two")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("three")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("four")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("five")).Count); Device dev = new Device("dev"); room.AddDevice(dev); tracker.UpdatePositionForDevice(dev, new Vector(-20,0)); Debug.Write(dev.Location.X + " " + dev.Location.Y); }
public void CoordinateTranslationTest() { Room r = new Room(); Tracker t = new Tracker("myKinect", new Point(5, 5), 270); r.AddTracker(t); Device one = new Device("one"); Device two = new Device("two"); Device three = new Device("three"); r.AddDevice(one); r.AddDevice(two); r.AddDevice(three); t.UpdatePositionForDevice(one, new Vector(1, 1)); t.UpdatePositionForDevice(two, new Vector(5, 0)); t.UpdatePositionForDevice(three, new Vector(3, -3)); Assert.AreEqual(one.Location.X, 6, 0.001); Assert.AreEqual(one.Location.Y, 4, 0.001); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); // test of translation alone Tracker t2 = new Tracker("kinect2", new Point(0, -10), 0.0); r.AddTracker(t2); t2.UpdatePositionForDevice(one, new Vector(6, 14)); t2.UpdatePositionForDevice(two, new Vector(5, 10)); t2.UpdatePositionForDevice(three, new Vector(2, 12)); Assert.AreEqual(one.Location.X, 6, 0.001); Assert.AreEqual(one.Location.Y, 4, 0.001); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); //test of rotation alone Tracker t3 = new Tracker("kinect3", new Point(0, 0), 135); t3.UpdatePositionForDevice(one, new Vector(-1.425, -7.0678)); t3.UpdatePositionForDevice(two, new Vector(-3.535, -3.535)); t3.UpdatePositionForDevice(three, new Vector(0, -Math.Sqrt(8))); Assert.AreEqual(one.Location.X, 6, 0.01); // to deal with horrible horrible rounding error introduced by hardcoded positions just above Assert.AreEqual(one.Location.Y, 4, 0.01); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); }