I have a mesh which is mostly planar I'd like to find all the coplanar faces by using normals. I'll take that by finding all normals pointing in the same direction; that is, checking all collinear normal vectors within a tolerance, by a dot product.
But that means I've to check by looping for every vector.
MatrixXd VL = ... // Collinear vectors list taken from mesh normals
collinearEpsilon = 1e-8;
for (long i = 0, j = 0; i < VL.rows(); i++)
{
// get previous vector
Vector3d p = VL.row(i);
// loop around last vector
j = i + 1;
if (j == size)
{
j = 0;
}
// get next vector
Vector3d n = VL.row(j);
// if dot product is one, they're colinear
VectorXd CL(1);
p = p.normalized();
n = n.normalized();
CL(0) = 1 - abs(p.dot(n));
// check with epsilon
if (CL.isZero(collinearEpsilon))
// vector is collinear
else
// exit on first non-collinear
}
Thus my question: is there a better way to check the collinearity of a set of vectors, all together in a more compact way without looping, in Eigen?
EDIT: added assuming mesh is mostly planar
question from:
https://stackoverflow.com/questions/65884682/eigen-how-to-find-all-coplanar-faces-from-triangle-mesh-normals-without-looping 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…