double dgConvexHull3DFace::Evalue (const dgBigVector* const pointArray, const dgBigVector& point) const { const dgBigVector& p0 = pointArray[m_index[0]]; const dgBigVector& p1 = pointArray[m_index[1]]; const dgBigVector& p2 = pointArray[m_index[2]]; double matrix[3][3]; for (int32_t i = 0; i < 3; i ++) { matrix[0][i] = p2[i] - p0[i]; matrix[1][i] = p1[i] - p0[i]; matrix[2][i] = point[i] - p0[i]; } double error; double det = Determinant3x3 (matrix, &error); double precision = double (1.0f) / double (1<<24); double errbound = error * precision; if (fabs(det) > errbound) { return det; } dgGoogol exactMatrix[3][3]; for (int32_t i = 0; i < 3; i ++) { exactMatrix[0][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]); exactMatrix[1][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]); exactMatrix[2][i] = dgGoogol(point[i]) - dgGoogol(p0[i]); } dgGoogol exactDet (Determinant3x3(exactMatrix)); det = exactDet.GetAproximateValue(); return det; }
//dgFloat64 dgDelaunayTetrahedralization::GetTetraVolume (const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3) const dgFloat64 dgDelaunayTetrahedralization::GetTetraVolume( const dgConvexHull4dTetraherum* const tetra) const { // dgBigVector p1p0 (p1.Sub4(p0)); // dgBigVector p2p0 (p2.Sub4(p0)); // dgBigVector p3p0 (p3.Sub4(p0)); // dgBigVector normal (p1p0.CrossProduct4 (p2p0, p3p0)); // dgFloat64 det = normal.m_w; const dgHullVector* const points = &m_points[0]; const dgBigVector &p0 = points[tetra->m_faces[0].m_index[0]]; const dgBigVector &p1 = points[tetra->m_faces[0].m_index[1]]; const dgBigVector &p2 = points[tetra->m_faces[0].m_index[2]]; const dgBigVector &p3 = points[tetra->m_faces[0].m_otherVertex]; dgFloat64 matrix[3][3]; for (dgInt32 i = 0; i < 3; i++) { matrix[0][i] = p2[i] - p0[i]; matrix[1][i] = p1[i] - p0[i]; matrix[2][i] = p3[i] - p0[i]; } dgFloat64 error; dgFloat64 det = Determinant3x3(matrix, &error); dgFloat64 precision = dgFloat64(1.0f) / dgFloat64(1 << 24); dgFloat64 errbound = error * precision; if (fabs(det) > errbound) { return det; } dgGoogol exactMatrix[3][3]; for (dgInt32 i = 0; i < 3; i++) { exactMatrix[0][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]); exactMatrix[1][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]); exactMatrix[2][i] = dgGoogol(p3[i]) - dgGoogol(p0[i]); } dgGoogol exactDet(Determinant3x3(exactMatrix)); det = exactDet.GetAproximateValue(); return det; }