Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
        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;
        }
        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));
        }
Exemple #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());
        }
Exemple #7
0
        public Direction ToDirection()
        {
            IntVector2 v = Normalize();

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