Fix growth vector calculation (do more vector reduction to avoid strange results from inverting badly conditioned matrix)

This commit is contained in:
Matthias Hochsteger 2024-10-31 15:49:41 +01:00
parent c27650af0a
commit c27dbdef30

View File

@ -63,12 +63,14 @@ Vec<3> CalcGrowthVector (FlatArray<Vec<3>> ns)
for (auto j : Range(3))
mat(i, j) = ns[i][j];
if (fabs(mat.Det()) > 1e-6)
if (fabs(mat.Det()) > 1e-2)
{
DenseMatrix mat(3, 3);
for (auto i : Range(3))
for (auto j : Range(3))
mat(i, j) = ns[i] * ns[j];
if (fabs(mat.Det()) > 1e-2)
{
Vector rhs(3);
rhs = 1.;
Vector res(3);
@ -81,6 +83,7 @@ Vec<3> CalcGrowthVector (FlatArray<Vec<3>> ns)
return growth;
}
}
}
auto [maxpos1, maxpos2] = FindCloseVectors(ns);
Array<Vec<3>> new_normals;
new_normals = ns;