コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #4
0
ファイル: IntVector3.cs プロジェクト: jaenudin86/dwarrowdelf
        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));
        }
コード例 #5
0
 public IntVector3 ToIntVector3()
 {
     return(new IntVector3(MyMath.Round(this.X), MyMath.Round(this.Y), MyMath.Round(this.Z)));
 }
コード例 #6
0
 public DoubleVector3 Round()
 {
     return(new DoubleVector3(MyMath.Round(this.X), MyMath.Round(this.Y), MyMath.Round(this.Z)));
 }