public void AddItemFOVTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

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

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, 5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 810);
            Assert.AreEqual(new Point3D(50, 0, 5), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(90, map.Items.ElementAt(0).Value.orientation);

            Assert.AreEqual(new Point3D(Math.Cos(97.5 * DegreeToRads), 0, Math.Sin(97.5 * DegreeToRads)), map.Items.ElementAt(0).Value.LeftFOV);
            Assert.AreEqual(new Point3D(Math.Cos(82.5 * DegreeToRads), 0, Math.Sin(82.5 * DegreeToRads)), map.Items.ElementAt(0).Value.RightFOV);

            Assert.IsTrue(map.ChangeOrientation(map.Items.ElementAt(0).Key, -30));
            Assert.AreEqual(60, map.Items.ElementAt(0).Value.orientation);
            Assert.AreEqual(new Point3D(Math.Cos(67.5 * DegreeToRads), 0, Math.Sin(67.5 * DegreeToRads)), map.Items.ElementAt(0).Value.LeftFOV);
            Assert.AreEqual(new Point3D(Math.Cos(52.5 * DegreeToRads), 0, Math.Sin(52.5 * DegreeToRads)), map.Items.ElementAt(0).Value.RightFOV);

            Assert.IsTrue(map.ChangeOrientation(map.Items.ElementAt(0).Key, -270));
            Assert.AreEqual(150, map.Items.ElementAt(0).Value.orientation);
            Assert.AreEqual(new Point3D(Math.Cos(157.5 * DegreeToRads), 0, Math.Sin(157.5 * DegreeToRads)), map.Items.ElementAt(0).Value.LeftFOV);
            Assert.AreEqual(new Point3D(Math.Cos(142.5 * DegreeToRads), 0, Math.Sin(142.5 * DegreeToRads)), map.Items.ElementAt(0).Value.RightFOV);
        }
        public void AddItemFromAnglesTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

            map.AddTracker("tracker1", new Point3D(85, 0, 85), -135);
            Assert.AreEqual(new Point3D(85, 0, 85), map.TrackerList.Values.ElementAt(0).TrackerPos);
            Assert.AreEqual(225, map.TrackerList.Values.ElementAt(0).AngleOffset);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(5, 0, 5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 45);
            Assert.AreEqual(new Point3D(85 - 5 * Math.Sqrt(2), 0, 85), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(45, map.Items.ElementAt(0).Value.orientation);

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(5, 0, 5 * Math.Sqrt(3)), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile2", 45);
            Assert.AreEqual(new Point3D(85 + 10 * Math.Cos(195 * DegreeToRads), 0, 85 + 10 * Math.Sin(195 * DegreeToRads)), map.Items.ElementAt(1).Value.coord);
            Assert.AreEqual(45, map.Items.ElementAt(1).Value.orientation);

            Assert.IsTrue(map.AddItem("mobile3", new Point3D(-5, 0, 5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile3", 25);
            Assert.AreEqual(new Point3D(85, 0, 85 - 5 * Math.Sqrt(2)), map.Items.ElementAt(2).Value.coord);
            Assert.AreEqual(25, map.Items.ElementAt(2).Value.orientation);

            Assert.IsTrue(map.AddItem("mobile4", new Point3D(-5, 0, 5 * Math.Sqrt(3)), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile4", 62);
            Assert.AreEqual(new Point3D(85 + 10 * Math.Cos(255 * DegreeToRads), 0, 85 + 10 * Math.Sin(255 * DegreeToRads)), map.Items.ElementAt(3).Value.coord);
            Assert.AreEqual(62, map.Items.ElementAt(3).Value.orientation);
        }
        public void RectSetLocationTest()
        {
            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"));
            Assert.AreEqual(225, map.Items.ElementAt(0).Value.orientation);
            map.ChangeAbsoluteOrientation("mobile1", 45);
            map.Items.ElementAt(0).Value.Shape = new Rectangle(1);
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Rectangle, map.Items.ElementAt(0).Value.Shape.Identity);

            Assert.IsTrue(map.Items.ElementAt(0).Value.SetLocation());
            Assert.AreEqual(45, map.Items.ElementAt(0).Value.orientation);
        }
        public void AbsoluteOrientationTest()
        {
            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"));
            Assert.AreEqual(225, map.Items.ElementAt(0).Value.orientation);
            map.ChangeAbsoluteOrientation("mobile1", 0);
            Assert.AreEqual(0, map.Items.ElementAt(0).Value.orientation);
            map.ChangeOrientation("mobile1", 55);
            Assert.AreEqual(55, map.Items.ElementAt(0).Value.orientation);
            map.ChangeAbsoluteOrientation("mobile1", 22.99);
            Assert.AreEqual(22.99, map.Items.ElementAt(0).Value.orientation);

            Assert.IsFalse(map.ChangeOrientation("hello", 55));
            Assert.IsFalse(map.ChangeAbsoluteOrientation("hello", 55));
        }
        public void CircleWithRangeIntersectTest()
        {
            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(2);
            map.Items.ElementAt(0).Value.SetLocation();

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

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

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

            Assert.IsTrue(map.AddItem("mobile4", new Point3D(10.5, 0, 10.5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile4", 45);

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

            map.MoveItem("mobile4", new Point3D(13, 0, 13), "tracker1");
            list = map.IntersectsWithRange("mobile1");
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("mobile2", list[0].Key);

            Assert.IsTrue(map.AddItem("mobile5", new Point3D(10.5, 0, 10.5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile5", 45);
            map.Items.ElementAt(4).Value.Shape = new Circle(1);

            list = map.IntersectsWithRange("mobile1");
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("mobile2", list[0].Key);
            Assert.AreEqual("mobile5", list[1].Key);
        }
        public void ShapeMoveTest()
        {
            RoomMap map = new RoomMap(100, 100);
            map.AddTracker("tracker1", new Point3D(50, 0, 0), 1170);

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

            Point3D rfov = map.Items.ElementAt(0).Value.RightFOV;
            Point3D lfov = map.Items.ElementAt(0).Value.LeftFOV;

            Assert.IsTrue(map.MoveItem("mobile1", new Point3D(22, 0, 10), "tracker1"));
            Assert.AreEqual(new Point3D(72, 0, 10), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(45, map.Items.ElementAt(0).Value.orientation);
            Assert.AreEqual(rfov, map.Items.ElementAt(0).Value.RightFOV);
            Assert.AreEqual(lfov, map.Items.ElementAt(0).Value.LeftFOV);
        }
        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 RotateRectTest()
        {
            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 Rectangle(1);
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Rectangle, map.Items.ElementAt(0).Value.Shape.Identity);

            map.Items.ElementAt(0).Value.RotateItem(-45);
            Assert.AreEqual(0, map.Items.ElementAt(0).Value.orientation);

            map.ChangeOrientation("mobile1", 94);
            Assert.AreEqual(94, map.Items.ElementAt(0).Value.orientation);
            Assert.AreEqual(new Point3D(Math.Cos(86.5 * DegreeToRads), 0, Math.Sin(86.5 * DegreeToRads)), map.Items.ElementAt(0).Value.RightFOV);
            Assert.AreEqual(new Point3D(Math.Cos(101.5 * DegreeToRads), 0, Math.Sin(101.5 * DegreeToRads)), map.Items.ElementAt(0).Value.LeftFOV);

            Point3D st = new Point3D(Math.Sqrt(2) / 2 * Math.Cos(139 * DegreeToRads) + map.Items.ElementAt(0).Value.coord.X, 0, Math.Sqrt(2) / 2 * Math.Sin(139 * DegreeToRads) + map.Items.ElementAt(0).Value.coord.Z);
            Point3D end = new Point3D(Math.Sqrt(2) / 2 * Math.Cos(229 * DegreeToRads) + map.Items.ElementAt(0).Value.coord.X, 0, Math.Sqrt(2) / 2 * Math.Sin(229 * DegreeToRads) + map.Items.ElementAt(0).Value.coord.Z);
            Assert.AreEqual(st, map.Items.ElementAt(0).Value.Shape.Edges[0].start);
            Assert.AreEqual(end, map.Items.ElementAt(0).Value.Shape.Edges[0].end);
        }
        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 ShapeConstructorTest()
        {
            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();
            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(4, map.Items.ElementAt(0).Value.Shape.Edges.Count);
        }
 public void IntersectsRangeNullParamTest()
 {
     RoomMap map = new RoomMap(100, 100);
     map.AddTracker("tracker1", new Point3D(5, 0, 5), 90);
     Assert.IsNull(map.IntersectsWithRange(""));
     Assert.IsNull(map.IntersectsWithRange("hi"));
     Assert.IsNull(map.IntersectsWithRange(null));
 }
        public void SetRangeTest()
        {
            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(2);
            map.Items.ElementAt(0).Value.SetLocation();
            map.Items.ElementAt(0).Value.Range = 0;
            Assert.AreEqual(0.5, map.Items.ElementAt(0).Value.Range);
            map.Items.ElementAt(0).Value.Range = 3;
            Assert.AreEqual(3, map.Items.ElementAt(0).Value.Range);
        }
        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 AddItemLocationTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

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

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, 5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", -360);
            Assert.AreEqual(new Point3D(50, 0, 5), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(0, map.Items.ElementAt(0).Value.orientation);

            Assert.IsFalse(map.ChangeOrientation("hello", 0));

            Assert.IsTrue(map.ChangeOrientation(map.Items.ElementAt(0).Key, 675));
            Assert.AreEqual(315, map.Items.ElementAt(0).Value.orientation);
            map.Items.ElementAt(0).Value.Shape = new Rectangle(2);
            Assert.AreEqual(2, ((Rectangle)map.Items.ElementAt(0).Value.Shape).Length);
            Assert.AreEqual(2, ((Rectangle)map.Items.ElementAt(0).Value.Shape).Width);
            Assert.AreEqual(new Point3D(50, 0, 5), map.Items.ElementAt(0).Value.coord);

            map.Items.ElementAt(0).Value.SetLocation();
            Assert.AreEqual(Shape.Rectangle, map.Items.ElementAt(0).Value.Shape.Identity);
            Assert.AreEqual(new Point3D(50, 0, 5 + Math.Sqrt(2)), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(1).start);
            ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(1).end.Z = Math.Floor(((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(1).end.Z);
            Assert.AreEqual(new Point3D(50 - Math.Sqrt(2), 0, 5), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(1).end);
            ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(2).start.Z = Math.Floor(((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(2).start.Z);
            Assert.AreEqual(new Point3D(50 - Math.Sqrt(2), 0, 5), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(2).start);
            Assert.AreEqual(new Point3D(50, 0, 5 - Math.Sqrt(2)), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(2).end);
            Assert.AreEqual(new Point3D(50, 0, 5 - Math.Sqrt(2)), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(3).start);
            ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(3).end.Z = Math.Ceiling(((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(3).end.Z);
            Assert.AreEqual(new Point3D(50 + Math.Sqrt(2), 0, 5), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(3).end);
            Assert.AreEqual(new Point3D(50 + Math.Sqrt(2), 0, 5), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(0).start);
            Assert.AreEqual(new Point3D(50, 0, 5 + Math.Sqrt(2)), ((Rectangle)map.Items.ElementAt(0).Value.Shape).Edges.ElementAt(0).end);

            Assert.IsTrue(map.AddItem("mobile2", new Point3D(10, 0, 10), "tracker1"));
            map.Items.ElementAt(1).Value.Shape = new Rectangle();
            ((Rectangle)map.Items.ElementAt(0).Value.Shape).CreateShape(2, 2);
            Assert.AreEqual(4, map.Items.ElementAt(0).Value.Shape.Area());
        }
        public void ResetMapTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

            map.ResetMap(250, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(250, map.Width);
        }
        public void RotateTrackerTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.IsFalse(map.RotateTracker("tracker1", 5));

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

            map.RotateTracker("tracker1", 5);
            Assert.AreEqual(50, map.TrackerList.Values.ElementAt(0).AngleOffset);
            map.RotateTracker("tracker1", 725);
            Assert.AreEqual(55, map.TrackerList.Values.ElementAt(0).AngleOffset);
        }
        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 FlickAngleTest()
        {
            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.Items.ElementAt(1).Value.Shape = new Circle(3);
            map.Items.ElementAt(1).Value.SetLocation();

            Assert.AreEqual(0, map.GetFlickAngle("mobile1", "mobile2"));
            map.ChangeAbsoluteOrientation("mobile2", 0);
            Assert.AreEqual(225, map.GetFlickAngle("mobile1", "mobile2"));
        }
        public void DeleteItemTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

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

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, Math.Sqrt(2)), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 0);
            Assert.AreEqual(new Point3D(6, 0, 6), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(0, map.Items.ElementAt(0).Value.orientation);
            Assert.IsFalse(map.DeleteItem("hello"));
            Assert.IsFalse(map.DeleteItem(new KeyValuePair<string, PointOrient>("hello", new PointOrient(new Point3D(0, 0, Math.Sqrt(2)), 0))));
            Assert.IsTrue(map.DeleteItem("mobile1"));

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, Math.Sqrt(2)), "tracker1"));
            map.ResetMap(50, 50);
            Assert.AreEqual(0, map.Items.Count);
            Assert.AreEqual(0, map.TrackerList.Count);
        }
        public void CreateMapTest()
        {
            RoomMap rm = new RoomMap();
            Assert.AreEqual(0, rm.Height);
            Assert.AreEqual(0, rm.Length);
            Assert.AreEqual(0, rm.Width);

            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);
        }
        public void AddMoveTrackerTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);
            Assert.IsFalse(map.MoveTracker("tracker1", new Point3D(5, 0, 5), 45));

            Assert.IsFalse(map.AddTracker("tracker1", new Point3D(-5, 0, 5), 45));
            Assert.IsFalse(map.AddTracker("tracker1", new Point3D(5, 0, -5), 45));
            Assert.IsFalse(map.AddTracker("tracker1", new Point3D(200, 0, 5), 45));
            Assert.IsFalse(map.AddTracker("tracker1", new Point3D(5, 0, 200), 45));

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

            map.MoveTracker("tracker1", new Point3D(10, 0, 5), 60);
            Assert.AreEqual(new Point3D(10, 0, 5), map.TrackerList.Values.ElementAt(0).TrackerPos);
            Assert.AreEqual(60, map.TrackerList.Values.ElementAt(0).AngleOffset);
        }
        public void AddItemTest()
        {
            RoomMap map = new RoomMap(100, 100);
            Assert.AreEqual(100, map.Length);
            Assert.AreEqual(100, map.Width);

            Assert.IsFalse(map.AddItem("mobile1", new Point3D(0, 0, Math.Sqrt(2)), "tracker1"));
            Assert.IsTrue(map.AddTracker("tracker1", new Point3D(5, 0, 5), 45 + 1080));
            Assert.AreEqual(new Point3D(5, 0, 5), map.TrackerList.Values.ElementAt(0).TrackerPos);
            Assert.AreEqual(45, map.TrackerList.Values.ElementAt(0).AngleOffset);

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, Math.Sqrt(2)), "tracker1"));
            Assert.AreEqual(new Point3D(6, 0, 6), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(225, map.Items.ElementAt(0).Value.orientation);
            Assert.IsFalse(map.AddItem("mobile1", new Point3D(2, 3, Math.Sqrt(2)), "tracker1"));
        }
        public void MoveItemTest()
        {
            RoomMap map = new RoomMap(100, 100);

            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(10, 0, 10), "tracker1"));
            map.AddTracker("tracker1", new Point3D(50, 0, 0), 1170);
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(10, 0, 10), "tracker1"));

            Assert.IsTrue(map.AddItem("mobile1", new Point3D(0, 0, 5), "tracker1"));
            map.ChangeAbsoluteOrientation("mobile1", 90);
            Assert.AreEqual(new Point3D(50, 0, 5), map.Items.ElementAt(0).Value.coord);
            Assert.AreEqual(90, map.Items.ElementAt(0).Value.orientation);

            map.MoveItem("mobile1", new Point3D(0, 0, 5), "tracker1");
            Assert.AreEqual(new Point3D(50, 0, 5), map.Items.ElementAt(0).Value.coord);
            map.MoveItem("mobile1", new Point3D(20, 0, 10), "tracker1");
            Assert.AreEqual(new Point3D(70, 0, 10), map.Items.ElementAt(0).Value.coord);

            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(-1, 0, 5), "tracker1"));
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(0, -1, 5), "tracker1"));
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(5, 0, -1), "tracker1"));
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(120, 0, 5), "tracker1"));
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(0, 10, 5), "tracker1"));
            Assert.IsFalse(map.MoveItem("mobile1", new Point3D(5, 0, 120), "tracker1"));
        }
 public void UnitTesting()
 {
     RoomMap map = new RoomMap(20, 20);
     Assert.IsNull(map.Intersects("hi"));
 }