Esempio n. 1
0
 /// <summary>
 /// Initializes a new Matrix2x3 class.
 /// </summary>
 static Matrix2x3()
 {
     Matrix2x3 m = default(Matrix2x3);
     m._values[0] = 1.0f;
     m._values[4] = 1.0f;
     Identity = m;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new Matrix2x3 class.
        /// </summary>
        static Matrix2x3()
        {
            Matrix2x3 m = default(Matrix2x3);

            m._values[0] = 1.0f;
            m._values[4] = 1.0f;
            Identity     = m;
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the inverse matrix of this matrix.
        /// </summary>
        /// <returns>Matrix2x3.</returns>
        public Matrix2x3 Invert()
        {
            Matrix2x3 m1 = this;
            Matrix2x3 m2 = Identity;

            if (m1._values[0] == 0 || m1._values[4] == 0)
            {
                if (m1._values[1] == 0 || m1._values[3] == 0)
                    throw new InvalidOperationException("This matrix is singular."); }

                m1.SwapRows();
                m2.SwapRows();
            }
Esempio n. 4
0
        /// <summary>
        /// Sets the Transform.
        /// </summary>
        /// <param name="matrix">The Matrix.</param>
        public void SetTransform(Matrix2x3 matrix)
        {
            Matrix m = Matrix.Identity;

            m.M12 = matrix[1, 0];
            m.M21 = matrix[0, 1];
            m.M11 = matrix[0, 0];
            m.M22 = matrix[1, 1];
            m.M33 = 1f;
            m.M41 = matrix.OffsetX;
            m.M42 = matrix.OffsetY;
            m.M43 = 0;

            _sprite.Transform = m;
        }
Esempio n. 5
0
        /// <summary>
        /// Sets the Transform.
        /// </summary>
        /// <param name="matrix">The Matrix.</param>
        public void SetTransform(Matrix2x3 matrix)
        {
            var dxMatrix = new Matrix3x2
            {
                M31 = matrix.OffsetX,
                M32 = matrix.OffsetY,
                M11 = matrix[0, 0],
                M22 = matrix[1, 1],
                M12 = matrix[1, 0],
                M21 = matrix[0, 1]
            };

            _renderTarget.Transform = dxMatrix;
        }
Esempio n. 6
0
 /// <summary>
 /// Sets the Transform.
 /// </summary>
 /// <param name="matrix">The Matrix.</param>
 public void SetTransform(Matrix2x3 matrix)
 {
     Renderer.SetTransform(matrix);
 }
Esempio n. 7
0
        /// <summary>
        /// Sets the Transform.
        /// </summary>
        /// <param name="matrix">The Matrix.</param>
        public void SetTransform(Matrix2x3 matrix)
        {
            var dxMatrix = new Matrix3x2
            {
                TranslationVector = DirectXHelper.ConvertVector(new Vector2(matrix.OffsetX, matrix.OffsetY)),
                ScaleVector = DirectXHelper.ConvertVector(new Vector2(matrix[0, 0], matrix[1, 1])),
                M12 = matrix[1, 0],
                M21 = matrix[0, 1]
            };

            DirectXHelper.RenderTarget.Transform = dxMatrix;
        }
Esempio n. 8
0
        /// <summary>
        /// Sets the Transform.
        /// </summary>
        /// <param name="matrix">The Matrix.</param>
        public void SetTransform(Matrix2x3 matrix)
        {
            var matrixf = new float[16];
            matrixf[0] = matrix[0, 0];
            matrixf[1] = matrix[1, 0];
            matrixf[2] = 0;
            matrixf[3] = 0;

            matrixf[4] = matrix[0, 1];
            matrixf[5] = matrix[1, 1];
            matrixf[6] = 0;
            matrixf[7] = 0;

            matrixf[8] = 0;
            matrixf[9] = 0;
            matrixf[10] = 1;
            matrixf[11] = 0;

            matrixf[12] = matrix.OffsetX;
            matrixf[13] = matrix.OffsetY;
            matrixf[14] = 0;
            matrixf[15] = 1;

            _matrix4 = matrixf;
        }
Esempio n. 9
0
 /// <summary>
 /// Multiplies two matrices.
 /// </summary>
 /// <param name="left">The left matrix.</param>
 /// <param name="right">The right matrix.</param>
 /// <returns>Matrix2x3.</returns>
 public static Matrix2x3 Multiply(Matrix2x3 left, Matrix2x3 right)
 {
     Matrix2x3 m = default(Matrix2x3);
     for (int x = 0; x < 2; x++)
     {
         for (int y = 0; y < 3; y++)
         {
             m[x, y] = left[x, 0]*right[0, y] + left[x, 1]*right[1, y] + (y == 2 ? left[x, 2] : 0);
         }
     }
     return m;
 }