bool IsContains(Vector3D p, Thetra t) { Vector3D a, b, c; bool ans = true; int[,] indexes = new int[4, 4] { { 1, 2, 0, 3 }, { 3, 2, 1, 0 }, { 1, 3, 0, 2 }, { 2, 3, 0, 1 } }; for (int i = 0; i < 4 && ans; i++) { a = Vector3D.Cross(points[t[indexes[i, 0]]] - points[t[indexes[i, 2]]], points[t[indexes[i, 1]]] - points[t[indexes[i, 2]]]); b = points[t[indexes[i, 3]]] - (points[t[indexes[i, 0]]] + points[t[indexes[i, 1]]] + points[t[indexes[i, 2]]]) / 3.0; c = p - (points[t[indexes[i, 0]]] + points[t[indexes[i, 1]]] + points[t[indexes[i, 2]]]) / 3.0; ans &= !((a * b >= 0) ^ (a * c >= 0)); } return(ans || t.data.Select(x => points[x]).Contains(p)); }
void MakeLocalMatrix(Thetra t) { double[,] data = new double[4, 4] { { 1, 1, 1, 1 }, { points[t[0]].X, points[t[1]].X, points[t[2]].X, points[t[3]].X }, { points[t[0]].Y, points[t[1]].Y, points[t[2]].Y, points[t[3]].Y }, { points[t[0]].Z, points[t[1]].Z, points[t[2]].Z, points[t[3]].Z } }; DenseMatrix a = (DenseMatrix)(new DenseMatrix(4, 4, data)).ReverseDefault(); double lambda = Material(t.mat); for (int i = 0; i < 4; i++) { LocalRightPart[i] = 0; for (int j = 0; j < 4; j++) { LocalMatrix[i, j] = lambda * Math.Abs(a.Det) / 6.0 * (a[i, 1] * a[j, 1] + a[i, 2] * a[j, 2] + a[i, 3] * a[j, 3]); LocalRightPart[i] += LocalM[i, j] * FunctionRightPart(points[t[j]].X, points[t[j]].Y, points[t[j]].Z, t.mat); koefs[t[i], j] = a[i, j]; } LocalRightPart[i] *= Math.Abs(a.Det) / 60; } }