decompose static method

void decompose(
  1. Mat2D m,
  2. TransformComponents result
)

Implementation

static void decompose(Mat2D m, TransformComponents result) {
  double m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3];

  double rotation = atan2(m1, m0);
  double denom = m0 * m0 + m1 * m1;
  double scaleX = sqrt(denom);
  double scaleY = (scaleX == 0) ? 0 : ((m0 * m3 - m2 * m1) / scaleX);
  double skewX = atan2(m0 * m2 + m1 * m3, denom);

  result[0] = m[4];
  result[1] = m[5];
  result[2] = scaleX;
  result[3] = scaleY;
  result[4] = rotation;
  result[5] = skewX;
}