diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-11-26 15:01:53 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-11-26 15:01:53 +0100 |
commit | 8518ba0bbc2ca5a70027ec6c4e6d4aac5218f353 (patch) | |
tree | d65f37a10a13222ab1032db3ef4be5a87d989fe1 /Eigen/src/Geometry/Hyperplane.h | |
parent | da584912b62742b6c4f453fb42eef863e406082d (diff) |
Fix Hyperplane::Through(a,b,c) when points are aligned or identical. We use the stratgey as in Quaternion::setFromTwoVectors.
Diffstat (limited to 'Eigen/src/Geometry/Hyperplane.h')
-rw-r--r-- | Eigen/src/Geometry/Hyperplane.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index aeff43fef..00b7c4300 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -100,7 +100,17 @@ public: { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3) Hyperplane result(p0.size()); - result.normal() = (p2 - p0).cross(p1 - p0).normalized(); + VectorType v0(p2 - p0), v1(p1 - p0); + result.normal() = v0.cross(v1); + RealScalar norm = result.normal().norm(); + if(norm <= v0.norm() * v1.norm() * NumTraits<RealScalar>::epsilon()) + { + Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose(); + JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV); + result.normal() = svd.matrixV().col(2); + } + else + result.normal() /= norm; result.offset() = -p0.dot(result.normal()); return result; } |