Esempio n. 1
0
        public IntVector2 Normalize()
        {
            double len = this.Length;
            var    x   = MyMath.Round(this.X / len);
            var    y   = MyMath.Round(this.Y / len);

            return(new IntVector2(x, y));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        public IntVector2 Rotate(int angle)
        {
            double rad = Math.PI * angle / 180.0;
            double x   = Math.Cos(rad) * this.X - Math.Sin(rad) * this.Y;
            double y   = Math.Sin(rad) * this.X + Math.Cos(rad) * this.Y;

            var ix = MyMath.Round(x);
            var iy = MyMath.Round(y);

            return(new IntVector2(ix, iy));
        }
Esempio n. 4
0
        public IntVector3 Normalize()
        {
            if (this.IsNull)
            {
                return(new IntVector3());
            }

            double len = this.Length;
            var    x   = MyMath.Round(this.X / len);
            var    y   = MyMath.Round(this.Y / len);
            var    z   = MyMath.Round(this.Z / len);

            return(new IntVector3(x, y, z));
        }
Esempio n. 5
0
 public IntVector3 ToIntVector3()
 {
     return(new IntVector3(MyMath.Round(this.X), MyMath.Round(this.Y), MyMath.Round(this.Z)));
 }
Esempio n. 6
0
 public DoubleVector3 Round()
 {
     return(new DoubleVector3(MyMath.Round(this.X), MyMath.Round(this.Y), MyMath.Round(this.Z)));
 }