solve method Null safety
Solve A
* x
= b
.
Implementation
static void solve(Matrix4 A, Vector4 x, Vector4 b) {
final a00 = A._m4storage[0];
final a01 = A._m4storage[1];
final a02 = A._m4storage[2];
final a03 = A._m4storage[3];
final a10 = A._m4storage[4];
final a11 = A._m4storage[5];
final a12 = A._m4storage[6];
final a13 = A._m4storage[7];
final a20 = A._m4storage[8];
final a21 = A._m4storage[9];
final a22 = A._m4storage[10];
final a23 = A._m4storage[11];
final a30 = A._m4storage[12];
final a31 = A._m4storage[13];
final a32 = A._m4storage[14];
final a33 = A._m4storage[15];
final b00 = a00 * a11 - a01 * a10;
final b01 = a00 * a12 - a02 * a10;
final b02 = a00 * a13 - a03 * a10;
final b03 = a01 * a12 - a02 * a11;
final b04 = a01 * a13 - a03 * a11;
final b05 = a02 * a13 - a03 * a12;
final b06 = a20 * a31 - a21 * a30;
final b07 = a20 * a32 - a22 * a30;
final b08 = a20 * a33 - a23 * a30;
final b09 = a21 * a32 - a22 * a31;
final b10 = a21 * a33 - a23 * a31;
final b11 = a22 * a33 - a23 * a32;
final bX = b.storage[0];
final bY = b.storage[1];
final bZ = b.storage[2];
final bW = b.storage[3];
var det =
b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (det != 0.0) {
det = 1.0 / det;
}
x
..x = det *
((a11 * b11 - a12 * b10 + a13 * b09) * bX -
(a10 * b11 - a12 * b08 + a13 * b07) * bY +
(a10 * b10 - a11 * b08 + a13 * b06) * bZ -
(a10 * b09 - a11 * b07 + a12 * b06) * bW)
..y = det *
-((a01 * b11 - a02 * b10 + a03 * b09) * bX -
(a00 * b11 - a02 * b08 + a03 * b07) * bY +
(a00 * b10 - a01 * b08 + a03 * b06) * bZ -
(a00 * b09 - a01 * b07 + a02 * b06) * bW)
..z = det *
((a31 * b05 - a32 * b04 + a33 * b03) * bX -
(a30 * b05 - a32 * b02 + a33 * b01) * bY +
(a30 * b04 - a31 * b02 + a33 * b00) * bZ -
(a30 * b03 - a31 * b01 + a32 * b00) * bW)
..w = det *
-((a21 * b05 - a22 * b04 + a23 * b03) * bX -
(a20 * b05 - a22 * b02 + a23 * b01) * bY +
(a20 * b04 - a21 * b02 + a23 * b00) * bZ -
(a20 * b03 - a21 * b01 + a22 * b00) * bW);
}