public void AddTriangleTest()
        {
            RoomMap map = new RoomMap(100, 100);
            map.AddTracker("tracker1", new Point3D(5, 0, 5), 1170);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            map.Items.ElementAt(0).Value.Shape = new Triangle(1, 2);
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Triangle, map.Items.ElementAt(0).Value.Shape.Identity);

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(14, 0, 14), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 45);
            map.Items.ElementAt(1).Value.Shape = new Triangle(1, 2);
            map.Items.ElementAt(1).Value.SetLocation();

            List<KeyValuePair<string, PointOrient>> list = map.Intersects("mobile1");
            Assert.AreEqual(1, list.Count);
            list = map.Intersects("mobile2");
            Assert.AreEqual(0, list.Count);
        }
        public void FindIntersectingItemsTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

            map.AddTracker("tracker1", new Point3D(5, 0, 5), 1170);
            Assert.AreEqual(new Point3D(5, 0, 5), map.TrackerList.Values.ElementAt(0).TrackerPos);
            Assert.AreEqual(90, map.TrackerList.Values.ElementAt(0).AngleOffset);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            map.Items.ElementAt(0).Value.Shape = new Rectangle(2);
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Rectangle, map.Items.ElementAt(0).Value.Shape.Identity);

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(17, 0, 17), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 45);
            map.Items.ElementAt(1).Value.Shape = new Rectangle(2);
            map.Items.ElementAt(1).Value.SetLocation();

            List<KeyValuePair<string, PointOrient>> list = map.Intersects("mobile1");
            Assert.AreEqual(1, list.Count);

            list = map.Intersects("mobile2");
            Assert.AreEqual(0, list.Count);

            map.MoveItem("mobile2", new Point3D(10.5, 0, 10.5), "tracker1");
            map.ChangeOrientation("mobile1", -45);
            list = map.Intersects("mobile2");
            Assert.AreEqual(1, list.Count);

            map.MoveItem("mobile2", new Point3D(9.5, 0, 9.5), "tracker1");
            list = map.Intersects("mobile2");
            Assert.AreEqual(1, list.Count);
        }
        public void MoreShapesTest()
        {
            RoomMap map = new RoomMap(100, 100);
            map.AddTracker("tracker1", new Point3D(5, 0, 5), 90);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            map.Items.ElementAt(0).Value.Shape = new Circle(3);
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Circle, map.Items.ElementAt(0).Value.Shape.Identity);

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(12.1, 0, 12.1), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 45);
            map.Items.ElementAt(1).Value.Shape = new Circle(3);
            map.Items.ElementAt(1).Value.SetLocation();

            List<KeyValuePair<string, PointOrient>> list = map.Intersects("mobile1");
            Assert.AreEqual(1, list.Count);
            map.Items.ElementAt(0).Value.RotateItem(-45);
            list = map.Intersects("mobile2");
            Assert.AreEqual(1, list.Count);
        }
        public void ManyTriangles360Test()
        {
            RoomMap map = new RoomMap(100, 100);
            map.AddTracker("tracker1", new Point3D(5, 0, 5), 90);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            map.Items.ElementAt(0).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(0).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(12, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 180);
            map.Items.ElementAt(1).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(1).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile3", new Point3D(12, 0, 12), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile3", 225);
            map.Items.ElementAt(2).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(2).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile4", new Point3D(10, 0, 12), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile4", 270);
            map.Items.ElementAt(3).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(3).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile5", new Point3D(8, 0, 12), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile5", 315);
            map.Items.ElementAt(4).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(4).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile6", new Point3D(8, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile6", 0);
            map.Items.ElementAt(5).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(5).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile7", new Point3D(8, 0, 8), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile7", 45);
            map.Items.ElementAt(6).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(6).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile8", new Point3D(10, 0, 8), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile8", 90);
            map.Items.ElementAt(7).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(7).Value.SetLocation();

            Assert.IsTrue(map.AddItem("mobile9", new Point3D(12, 0, 8), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile9", 135);
            map.Items.ElementAt(8).Value.Shape = new Triangle(1, 0.5);
            map.Items.ElementAt(8).Value.SetLocation();

            List<KeyValuePair<string, PointOrient>> list = map.Intersects("mobile2");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile6", list[1].Key);

            list = map.Intersects("mobile3");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile7", list[1].Key);

            list = map.Intersects("mobile4");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile8", list[1].Key);

            list = map.Intersects("mobile5");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile9", list[1].Key);

            list = map.Intersects("mobile6");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile2", list[1].Key);

            list = map.Intersects("mobile7");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile3", list[1].Key);

            list = map.Intersects("mobile8");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile4", list[1].Key);

            list = map.Intersects("mobile9");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile1", list[0].Key);
            Assert.AreEqual("mobile5", list[1].Key);
        }
        public void ShapNullIntersectTest()
        {
            RoomMap map = new RoomMap(100, 100);
            map.AddTracker("tracker1", new Point3D(5, 0, 5), 1170);
            Assert.IsTrue(map.AddItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            Assert.IsTrue(map.AddItem("mobile2", new Point3D(15, 0, 15), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 45);

            List<KeyValuePair<string, PointOrient>> list = map.Intersects("mobile1");
            Assert.AreEqual(1, list.Count);
            list = map.Intersects("mobile2");
            Assert.AreEqual(0, list.Count);
        }
 public void UnitTesting()
 {
     RoomMap map = new RoomMap(20, 20);
     Assert.IsNull(map.Intersects("hi"));
 }