invert static method

bool invert(
  1. Mat2D o,
  2. Mat2D a
)

Implementation

static bool invert(Mat2D o, Mat2D a) {
  double aa = a[0], ab = a[1], ac = a[2], ad = a[3], atx = a[4], aty = a[5];

  double det = aa * ad - ab * ac;
  if (det == 0.0) {
    return false;
  }
  det = 1.0 / det;

  o[0] = ad * det;
  o[1] = -ab * det;
  o[2] = -ac * det;
  o[3] = aa * det;
  o[4] = (ac * aty - ad * atx) * det;
  o[5] = (ab * atx - aa * aty) * det;
  return true;
}