Ejemplo n.º 1
0
 public static Vector2 Multiply(ref Matrix3x2 m, Vector2 v)
 {
     return new Vector2(
         m.M00 * v.X + m.M10 * v.Y + m.M20,
         m.M01 * v.X + m.M11 * v.Y + m.M21
     );
 }
Ejemplo n.º 2
0
        public static void Multiply(ref Matrix3x2 left, ref Matrix3x2 right, out Matrix3x2 result)
        {
            result = new Matrix3x2(
                left.M00 * right.M00 + left.M10 * right.M01,
                left.M01 * right.M00 + left.M11 * right.M01,

                left.M00 * right.M10 + left.M10 * right.M11,
                left.M01 * right.M10 + left.M11 * right.M11,

                left.M00 * right.M20 + left.M10 * right.M21 + left.M20,
                left.M01 * right.M20 + left.M11 * right.M21 + left.M21
            );
        }
Ejemplo n.º 3
0
 public void Clear()
 {
     m_queueSize = 0;
     m_transformStack.Clear();
     m_transform = Matrix3x2.Identity;
 }
Ejemplo n.º 4
0
        public void Translate(Vector2 v)
        {
            // M00 M10 M20
            // M01 M11 M21

            // 1   0   v.X
            // 0   1   v.Y

            m_transform = new Matrix3x2(
                m_transform.M00,
                m_transform.M01,

                m_transform.M10,
                 m_transform.M11,

                m_transform.M00 * v.X + m_transform.M10 * v.Y + m_transform.M20,
                m_transform.M01 * v.X + m_transform.M11 * v.Y + m_transform.M21
            );
        }
Ejemplo n.º 5
0
        public void Scale(Vector2 v)
        {
            // M00 M10 M20
            // M01 M11 M21

            // v.X 0   0
            // 0   v.Y 0

            m_transform = new Matrix3x2(
                m_transform.M00 * v.X,
                m_transform.M01 * v.X,

                m_transform.M10 * v.Y,
                m_transform.M11 * v.Y,

                m_transform.M20,
                m_transform.M21
            );
        }
Ejemplo n.º 6
0
        public void Rotate(float angle)
        {
            // M00 M10 M20
            // M01 M11 M21

            // c   s   0
            // -s   c  0

            var c = (float)Math.Cos(angle);
            var s = (float)Math.Sin(angle);

            m_transform = new Matrix3x2(
                m_transform.M00 * c - m_transform.M10 * s,
                m_transform.M01 * c - m_transform.M11 * s,

                m_transform.M00 * s + m_transform.M10 * c,
                m_transform.M01 * s + m_transform.M11 * c,

                m_transform.M20,
                m_transform.M21
            );
        }
Ejemplo n.º 7
0
 public void PopTransform()
 {
     m_transform = m_transformStack.Pop();
 }
Ejemplo n.º 8
0
        public void Ortho(float left, float right, float bottom, float top)
        {
            var right_minus_left = right - left;
            var top_minus_bottom = top - bottom;

            m_transform = new Matrix3x2(
                2 / right_minus_left, 0,
                0, 2 / top_minus_bottom,
                -(right + left) / right_minus_left,
                -(top + bottom) / top_minus_bottom
            );
        }