Пример #1
0
 public void Move(int x, int y)
 {
     transformMatrix = transformMatrix.Mul(
         new HMatrix(
             1, 0, 0,
             0, 1, 0,
             x, y, 1));
 }
Пример #2
0
 public void Move(int x, int y)
 {
     transformMatrix = transformMatrix.Mul(
         new HMatrix(
             1, 0, 0,
             0, 1, 0,
             x, y, 1));
 }
Пример #3
0
 public void Scale(double z1, double z2)
 {
     transformMatrix = transformMatrix.Mul(
         new HMatrix(
             z1, 0, 0,
             0, z2, 0,
             0, 0, 1));
 }
Пример #4
0
        private HPoint TransformPointRelative(HPoint p)
        {
            var t = new HMatrix(transformMatrix);

            t[2, 0] = 0;
            t[2, 1] = 0;
            return(t.Mul(p));
        }
Пример #5
0
        public void Rotate(int rotate)
        {
            var a = -rotate / 180.0d * Math.PI;

            transformMatrix = transformMatrix.Mul(
                new HMatrix(
                    Math.Cos(a), -Math.Sin(a), 0,
                    Math.Sin(a), Math.Cos(a), 0,
                    0, 0, 1));
        }
Пример #6
0
 public bool Equals(HMatrix m)
 {
     for (int x = 0; x < 3; x++)
     {
         for (int y = 0; y < 3; y++)
         {
             if (this[x, y] != m[x, y])
                 return false;
         }
     }
     return true;
 }
Пример #7
0
 public bool Equals(HMatrix m)
 {
     for (int x = 0; x < 3; x++)
     {
         for (int y = 0; y < 3; y++)
         {
             if (this[x, y] != m[x, y])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #8
0
        public HMatrix Mul(HMatrix by)
        {
            var result = new HMatrix();
            var r      = result.values;
            var a      = this.values;
            var b      = by.values;

            r[0, 0] = a[0, 0] * b[0, 0] + a[0, 1] * b[1, 0] + a[0, 2] * b[2, 0];
            r[0, 1] = a[0, 0] * b[0, 1] + a[0, 1] * b[1, 1] + a[0, 2] * b[2, 1];
            r[0, 2] = a[0, 0] * b[0, 2] + a[0, 1] * b[1, 2] + a[0, 2] * b[2, 2];

            r[1, 0] = a[1, 0] * b[0, 0] + a[1, 1] * b[1, 0] + a[1, 2] * b[2, 0];
            r[1, 1] = a[1, 0] * b[0, 1] + a[1, 1] * b[1, 1] + a[1, 2] * b[2, 1];
            r[1, 2] = a[1, 0] * b[0, 2] + a[1, 1] * b[1, 2] + a[1, 2] * b[2, 2];

            r[2, 0] = a[2, 0] * b[0, 0] + a[2, 1] * b[1, 0] + a[2, 2] * b[2, 0];
            r[2, 1] = a[2, 0] * b[0, 1] + a[2, 1] * b[1, 1] + a[2, 2] * b[2, 1];
            r[2, 2] = a[2, 0] * b[0, 2] + a[2, 1] * b[1, 2] + a[2, 2] * b[2, 2];
            return(result);
        }
Пример #9
0
 public void Scale(double z1, double z2)
 {
     transformMatrix = transformMatrix.Mul(
         new HMatrix(
             z1, 0, 0,
             0, z2, 0,
             0, 0, 1));
 }
Пример #10
0
 public void Rotate(int rotate)
 {
     var a = -rotate / 180.0d * Math.PI;
     transformMatrix = transformMatrix.Mul(
         new HMatrix(
             Math.Cos(a), -Math.Sin(a), 0,
             Math.Sin(a), Math.Cos(a), 0,
             0, 0, 1));
 }
Пример #11
0
 public Transformer()
 {
     transformMatrix = new HMatrix(HMatrix.Identity);
 }
Пример #12
0
 private HPoint TransformPointRelative(HPoint p)
 {
     var t = new HMatrix(transformMatrix);
     t[2, 0] = 0;
     t[2, 1] = 0;
     return t.Mul(p);
 }
Пример #13
0
        public HMatrix Mul(HMatrix by)
        {
            var result = new HMatrix();
            var r = result.values;
            var a = this.values;
            var b = by.values;
            r[0, 0] = a[0, 0] * b[0, 0] + a[0, 1] * b[1, 0] + a[0, 2] * b[2, 0];
            r[0, 1] = a[0, 0] * b[0, 1] + a[0, 1] * b[1, 1] + a[0, 2] * b[2, 1];
            r[0, 2] = a[0, 0] * b[0, 2] + a[0, 1] * b[1, 2] + a[0, 2] * b[2, 2];

            r[1, 0] = a[1, 0] * b[0, 0] + a[1, 1] * b[1, 0] + a[1, 2] * b[2, 0];
            r[1, 1] = a[1, 0] * b[0, 1] + a[1, 1] * b[1, 1] + a[1, 2] * b[2, 1];
            r[1, 2] = a[1, 0] * b[0, 2] + a[1, 1] * b[1, 2] + a[1, 2] * b[2, 2];

            r[2, 0] = a[2, 0] * b[0, 0] + a[2, 1] * b[1, 0] + a[2, 2] * b[2, 0];
            r[2, 1] = a[2, 0] * b[0, 1] + a[2, 1] * b[1, 1] + a[2, 2] * b[2, 1];
            r[2, 2] = a[2, 0] * b[0, 2] + a[2, 1] * b[1, 2] + a[2, 2] * b[2, 2];
            return result;
        }
Пример #14
0
 public HMatrix(HMatrix source)
     : this()
 {
     Array.Copy(source.values, this.values, source.values.LongLength);
 }
Пример #15
0
 public HMatrix(HMatrix source) : this()
 {
     Array.Copy(source.values, this.values, source.values.LongLength);
 }
Пример #16
0
 public Transformer()
 {
     transformMatrix = new HMatrix(HMatrix.Identity);
 }