Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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 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);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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);
        }