solve3 static method
Solve A
* x
= b
.
Implementation
static void solve3(Matrix4 A, Vector3 x, Vector3 b) {
final A0x = A.entry(0, 0);
final A0y = A.entry(1, 0);
final A0z = A.entry(2, 0);
final A1x = A.entry(0, 1);
final A1y = A.entry(1, 1);
final A1z = A.entry(2, 1);
final A2x = A.entry(0, 2);
final A2y = A.entry(1, 2);
final A2z = A.entry(2, 2);
final bx = b.x - A._m4storage[12];
final by = b.y - A._m4storage[13];
final bz = b.z - A._m4storage[14];
double rx, ry, rz;
double det;
// Column1 cross Column 2
rx = A1y * A2z - A1z * A2y;
ry = A1z * A2x - A1x * A2z;
rz = A1x * A2y - A1y * A2x;
// A.getColumn(0).dot(x)
det = A0x * rx + A0y * ry + A0z * rz;
if (det != 0.0) {
det = 1.0 / det;
}
// b dot [Column1 cross Column 2]
final x_ = det * (bx * rx + by * ry + bz * rz);
// Column2 cross b
rx = -(A2y * bz - A2z * by);
ry = -(A2z * bx - A2x * bz);
rz = -(A2x * by - A2y * bx);
// Column0 dot -[Column2 cross b (Column3)]
final y_ = det * (A0x * rx + A0y * ry + A0z * rz);
// b cross Column 1
rx = -(by * A1z - bz * A1y);
ry = -(bz * A1x - bx * A1z);
rz = -(bx * A1y - by * A1x);
// Column0 dot -[b cross Column 1]
final z_ = det * (A0x * rx + A0y * ry + A0z * rz);
x
..x = x_
..y = y_
..z = z_;
}