copyInverse method Null safety

double copyInverse(
  1. Matrix3 arg
)

Set this matrix to be the inverse of arg

Implementation

double copyInverse(Matrix3 arg) {
  final det = arg.determinant();
  if (det == 0.0) {
    setFrom(arg);
    return 0.0;
  }
  final invDet = 1.0 / det;
  final argStorage = arg._m3storage;
  final ix = invDet *
      (argStorage[4] * argStorage[8] - argStorage[5] * argStorage[7]);
  final iy = invDet *
      (argStorage[2] * argStorage[7] - argStorage[1] * argStorage[8]);
  final iz = invDet *
      (argStorage[1] * argStorage[5] - argStorage[2] * argStorage[4]);
  final jx = invDet *
      (argStorage[5] * argStorage[6] - argStorage[3] * argStorage[8]);
  final jy = invDet *
      (argStorage[0] * argStorage[8] - argStorage[2] * argStorage[6]);
  final jz = invDet *
      (argStorage[2] * argStorage[3] - argStorage[0] * argStorage[5]);
  final kx = invDet *
      (argStorage[3] * argStorage[7] - argStorage[4] * argStorage[6]);
  final ky = invDet *
      (argStorage[1] * argStorage[6] - argStorage[0] * argStorage[7]);
  final kz = invDet *
      (argStorage[0] * argStorage[4] - argStorage[1] * argStorage[3]);
  _m3storage[0] = ix;
  _m3storage[1] = iy;
  _m3storage[2] = iz;
  _m3storage[3] = jx;
  _m3storage[4] = jy;
  _m3storage[5] = jz;
  _m3storage[6] = kx;
  _m3storage[7] = ky;
  _m3storage[8] = kz;
  return det;
}