From b84879685297955844d59394432839385224a829 Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Wed, 10 Jul 2019 12:56:37 +0200 Subject: [PATCH] Nativepolytope: Fixed a bug in quickhull when invoked on just a single point. --- .../nativepolytopeconversion/QuickHull.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/storm/storage/geometry/nativepolytopeconversion/QuickHull.cpp b/src/storm/storage/geometry/nativepolytopeconversion/QuickHull.cpp index 76a1a92a6..67a9f2942 100644 --- a/src/storm/storage/geometry/nativepolytopeconversion/QuickHull.cpp +++ b/src/storm/storage/geometry/nativepolytopeconversion/QuickHull.cpp @@ -128,11 +128,17 @@ namespace storm { // get one hyperplane that holds all points const uint_fast64_t dimension = points.front().rows(); EigenVector refPoint = points.front(); - EigenMatrix constraints(points.size() - 1, dimension); - for (unsigned row = 1; row < points.size(); ++row) { - constraints.row(row - 1) = points[row] - refPoint; + EigenVector normal; + if (points.size() == 1) { + normal.resize(dimension); + normal(0) = storm::utility::one(); + } else { + EigenMatrix constraints(points.size() - 1, dimension); + for (unsigned row = 1; row < points.size(); ++row) { + constraints.row(row - 1) = points[row] - refPoint; + } + normal = constraints.fullPivLu().kernel().col(0); } - EigenVector normal = constraints.fullPivLu().kernel().col(0); // Eigen returns the column vector 0...0 if the kernel is empty (i.e., there is no such hyperplane) if (normal.isZero()) {