ARdouble arMatrixDet(ARMat *m) { if(m->row != m->clm) return 0.0; return mdet(m->m, m->row, m->row); }
double matrixDet(Mat m) { if(m.row != m.clm) { return 0; } return mdet(m.m, m.row, m.row); }
bool csDIntersect3::Planes ( const csDPlane &p1, const csDPlane &p2, const csDPlane &p3, csDVector3 &isect) { //To find the one point that is on all three planes, we need to solve //the following equation system (we need to find the x, y and z which //are true for all equations): // A1*x+B1*y+C1*z+D1=0 //plane1 // A2*x+B2*y+C2*z+D2=0 //plane2 // A3*x+B3*y+C3*z+D3=0 //plane3 //This can be solved according to Cramers rule by looking at the //determinants of the equation system. csDMatrix3 mdet ( p1.A (), p1.B (), p1.C (), p2.A (), p2.B (), p2.C (), p3.A (), p3.B (), p3.C ()); double det = mdet.Determinant (); if (det == 0) return false; //some planes are parallel. csDMatrix3 mx ( -p1.D (), p1.B (), p1.C (), -p2.D (), p2.B (), p2.C (), -p3.D (), p3.B (), p3.C ()); double xdet = mx.Determinant (); csDMatrix3 my ( p1.A (), -p1.D (), p1.C (), p2.A (), -p2.D (), p2.C (), p3.A (), -p3.D (), p3.C ()); double ydet = my.Determinant (); csDMatrix3 mz ( p1.A (), p1.B (), -p1.D (), p2.A (), p2.B (), -p2.D (), p3.A (), p3.B (), -p3.D ()); double zdet = mz.Determinant (); isect.x = xdet / det; isect.y = ydet / det; isect.z = zdet / det; return true; }