+ if (IsIdentity())
+ {
+ tx = x;
+ ty = y;
+ return true;
+ }
+
+ const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2];
+ if ( wxIsNullDouble(z) )
+ return false;
+
+ tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0];
+ ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1];
+ return true;
+}
+
+wxTransformMatrix& wxTransformMatrix::operator*=(const double& t)
+{
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ m_matrix[i][j]*= t;
+ m_isIdentity = IsIdentity1();
+ return *this;
+}
+
+wxTransformMatrix& wxTransformMatrix::operator/=(const double& t)
+{
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ m_matrix[i][j]/= t;
+ m_isIdentity = IsIdentity1();
+ return *this;
+}
+
+wxTransformMatrix& wxTransformMatrix::operator+=(const wxTransformMatrix& mat)
+{
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ m_matrix[i][j] += mat.m_matrix[i][j];
+ m_isIdentity = IsIdentity1();
+ return *this;
+}
+
+wxTransformMatrix& wxTransformMatrix::operator-=(const wxTransformMatrix& mat)
+{
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ m_matrix[i][j] -= mat.m_matrix[i][j];
+ m_isIdentity = IsIdentity1();
+ return *this;
+}
+
+wxTransformMatrix& wxTransformMatrix::operator*=(const wxTransformMatrix& mat)
+{
+
+ if (mat.m_isIdentity)
+ return *this;
+ if (m_isIdentity)
+ {
+ *this = mat;
+ return *this;
+ }
+ else
+ {
+ wxTransformMatrix result;
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < 3; k++)
+ sum += m_matrix[k][i] * mat.m_matrix[j][k];
+ result.m_matrix[j][i] = sum;
+ }
+ }
+ *this = result;
+ }
+
+ m_isIdentity = IsIdentity1();
+ return *this;
+}
+
+
+// constant operators
+wxTransformMatrix wxTransformMatrix::operator*(const double& t) const
+{
+ wxTransformMatrix result = *this;
+ result *= t;
+ result.m_isIdentity = result.IsIdentity1();
+ return result;
+}
+
+wxTransformMatrix wxTransformMatrix::operator/(const double& t) const
+{
+ wxTransformMatrix result = *this;
+// wxASSERT(t!=0);
+ result /= t;
+ result.m_isIdentity = result.IsIdentity1();
+ return result;
+}
+
+wxTransformMatrix wxTransformMatrix::operator+(const wxTransformMatrix& m) const
+{
+ wxTransformMatrix result = *this;
+ result += m;
+ result.m_isIdentity = result.IsIdentity1();
+ return result;
+}
+
+wxTransformMatrix wxTransformMatrix::operator-(const wxTransformMatrix& m) const
+{
+ wxTransformMatrix result = *this;
+ result -= m;
+ result.m_isIdentity = result.IsIdentity1();
+ return result;
+}