Esempio n. 1
0
 static Matrix2x3()
 {
     Matrix2x3 m = default(Matrix2x3);
     m.values[0] = 1.0f;
     m.values[4] = 1.0f;
     Identity = m;
 }
Esempio n. 2
0
        static Matrix2x3()
        {
            Matrix2x3 m = default(Matrix2x3);

            m.values[0] = 1.0f;
            m.values[4] = 1.0f;
            Identity    = m;
        }
Esempio n. 3
0
        protected override Vector2 GetTexturePosition(Vector2 vertex, Matrix2x3 inverseTransform)
        {
            if (texture == null) return Vector2.Zero;

            Vector2 textPos = inverseTransform.ApplyTo(vertex);
            textPos.X /= texture.Width;
            textPos.Y /= texture.Height;
            return textPos;
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the inverse matrix of this matrix.
        /// </summary>
        /// <exception cref="InvalidOperationException">Is thrown when the matrix is singular an therefore not invertible.</exception>
        public Matrix2x3 Invert()
        {
            Matrix2x3 m1 = this;
            Matrix2x3 m2 = Matrix2x3.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. 5
0
 /// <summary>
 /// Multiplies zwo matrices.
 /// </summary>
 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;
 }
Esempio n. 6
0
 /// <summary>
 /// Resets the world transformation matrix to the identity matrix.
 /// </summary>
 public void ResetTransform()
 {
     Transform = Matrix2x3.Identity;
 }
Esempio n. 7
0
 protected virtual Math.Vector2 GetTexturePosition(Math.Vector2 vertex, Matrix2x3 inverseTransform)
 {
     return Math.Vector2.Zero;
 }