public void AngleNormalizeTest()
 {
     PointOrient po = new PointOrient();
     po.RotateItem(729);
     Assert.AreEqual(9, po.orientation);
     po = new PointOrient();
     po.RotateItem(-729);
     Assert.AreEqual(351, po.orientation);
 }
        /// <summary>
        /// Initializes relative settings for items mapped by tracker.
        /// </summary>
        /// <returns>Returns a PointOrient struct that contains the mapping info of the object.</returns>
        internal void InitItem(PointOrient po)
        {
            double theta = Math.Atan(po.coord.Z / po.coord.X) * RadsToDegree;
            double thypo = Math.Sqrt(Square(po.coord.X) + Square(po.coord.Z));
            double phi = Math.Atan(po.coord.Y / po.coord.X) * RadsToDegree;
            double phypo = Math.Sqrt(Square(po.coord.X) + Square(po.coord.Y));

            if (theta >= 0)
                theta = AngleOffset - 90 + theta;
            else
                theta = (90 + AngleOffset) + theta;

            double x = thypo * Math.Cos(theta * DegreeToRads) + TrackerPos.X;
            double y = 0;
            double z = thypo * Math.Sin(theta * DegreeToRads) + TrackerPos.Z;

            po.coord = new Point3D(x, y, z);
        }
        public void ShapeUnitTestingPart1()
        {
            PointOrient po = new PointOrient();

            po.Shape = new Rectangle();
            Assert.AreEqual(Shape.Rectangle, po.Shape.Identity);
            po.Shape.CreateShape(2, 2);
            Assert.AreEqual(4, po.Shape.Area());

            po.Shape = new Circle();
            Assert.AreEqual(Shape.Circle, po.Shape.Identity);
            po.Shape.CreateShape(5);
            Assert.AreEqual(Math.PI * 25, po.Shape.Area());

            po.Shape = new Triangle();
            Assert.AreEqual(Shape.Triangle, po.Shape.Identity);
            po.Shape.CreateShape(5, 2);
            Assert.AreEqual(5, po.Shape.Area());
        }
        public void ShapeUnitTestingPart2()
        {
            PointOrient po = new PointOrient();

            po.Shape = new Rectangle();
            Assert.AreEqual(Shape.Rectangle, po.Shape.Identity);
            po.Shape.CreateShape(-2, -2);
            Assert.AreEqual(2, ((Rectangle)po.Shape).Length);
            Assert.AreEqual(2, ((Rectangle)po.Shape).Width);
            Assert.AreEqual(4, po.Shape.Area());

            po.Shape = new Circle();
            Assert.AreEqual(Shape.Circle, po.Shape.Identity);
            po.Shape.CreateShape(-7);
            Assert.AreEqual(7, ((Circle)po.Shape).Radius);
            Assert.AreEqual(Math.PI * 49, po.Shape.Area());

            po.Shape = new Triangle();
            Assert.AreEqual(Shape.Triangle, po.Shape.Identity);
            po.Shape.CreateShape(-5, -3);
            Assert.AreEqual(5, ((Triangle)po.Shape).Base);
            Assert.AreEqual(3, ((Triangle)po.Shape).Height);
            Assert.AreEqual(7.5, po.Shape.Area());
        }
 /// <summary>
 /// Initializes the orientation of the added item to the direction of the tracker.
 /// </summary>
 internal void InitOrientation(PointOrient po)
 {
     double deltax = TrackerPos.X - po.coord.X;
     double deltaz = TrackerPos.Z - po.coord.Z;
     if (deltax < 0)
         po.orientation = 180 + Math.Atan(deltaz / deltax) * RadsToDegree;
     else
         po.orientation = Math.Atan(deltaz / deltax) * RadsToDegree;
     po.orientation = NormalizeAngle(po.orientation);
 }
 public void PointOrientUnitTesting()
 {
     PointOrient po = new PointOrient();
     Assert.AreEqual(new Point3D(0, 0, 0), po.coord);
     Assert.AreEqual(0, po.orientation);
 }
Example #7
0
        /// <summary>
        /// Add a new device to the Items list.
        /// </summary>
        /// <param name="orientation">The angle of orientation is relavent to the x-axis increasingly in a CCW direction.</param>
        /// <returns>Returns true if added else list already contains an item with that name or tracker is null.</returns>
        public bool AddItem(string name, Point3D point, string trackerName)
        {
            if (!trackerList.ContainsKey(trackerName) || items.ContainsKey(name))
                return false;

            PointOrient po = new PointOrient(point);
            int index = trackerList.Keys.ToList().IndexOf(trackerName);
            trackerList.Values.ElementAt(index).InitItem(po);
            trackerList.Values.ElementAt(index).InitOrientation(po);
            CalcItemsFOV(po);
            items.Add(name, po);

            return true;
        }
Example #8
0
        /// <summary>
        /// Determines the FOV for the current orientation of an item.
        /// </summary>
        /// <returns>Returns an object containing directional info and mapping of the item.</returns>
        private void CalcItemsFOV(PointOrient current)
        {
            double angle = current.orientation;

            current.LeftFOV = new Point3D(Math.Cos((angle + 7.5) * DegreeToRads), 0, Math.Sin((angle + 7.5) * DegreeToRads));
            current.RightFOV = new Point3D(Math.Cos((angle - 7.5) * DegreeToRads), 0, Math.Sin((angle - 7.5) * DegreeToRads));
        }