Ejemplo n.º 1
0
        public static IntVector2 operator +(IntVector2 left, Direction right)
        {
            int x, y;

            DirectionExtensions.DirectionToComponents(right, out x, out y);

            return(new IntVector2(left.X + x, left.Y + y));
        }
Ejemplo n.º 2
0
        public static IntVector3 operator +(IntVector3 left, Direction right)
        {
            int x, y, z;

            DirectionExtensions.DirectionToComponents(right, out x, out y, out z);

            return(new IntVector3(left.X + x, left.Y + y, left.Z + z));
        }
Ejemplo n.º 3
0
        public static IntVector2 ToIntVector2(this Direction dir)
        {
            Debug.Assert(dir.IsValid());

            int x, y;

            DirectionExtensions.DirectionToComponents(dir, out x, out y);

            return(new IntVector2(x, y));
        }
Ejemplo n.º 4
0
        public DoubleVector3(Direction dir)
        {
            int x, y, z;

            DirectionExtensions.DirectionToComponents(dir, out x, out y, out z);

            m_x = x;
            m_y = y;
            m_z = z;
        }
Ejemplo n.º 5
0
        public Direction ToDirection()
        {
            DoubleVector3 v = Normalize();

            int x = MyMath.Round(v.X);
            int y = MyMath.Round(v.Y);
            int z = MyMath.Round(v.Z);

            return(DirectionExtensions.ComponentsToDirection(x, y, z));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Rotate dir in 45 degree steps
        /// </summary>
        /// <param name="rotate">Rotation units, in 45 degree steps</param>
        public static Direction RotateDir(Direction dir, int rotate)
        {
            int x, y;

            DirectionExtensions.DirectionToComponents(dir, out x, out y);

            IntVector2 v = new IntVector2(x, y);

            v = v.FastRotate(rotate);
            return(v.ToDirection());
        }
Ejemplo n.º 7
0
        public Direction ToDirection()
        {
            IntVector2 v = Normalize();

            return(DirectionExtensions.ComponentsToDirection(v.X, v.Y));
        }