From cf59f9ff6a8eb98441942ca7d8618dfa31361e93 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 26 Aug 2007 17:16:03 +0000 Subject: Rewrite of z-order code for 3D boxes, first stage (hopefully this is finally the right approach) (bzr r3586) --- src/line-geometry.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/line-geometry.cpp') diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index f6f411bff..000da8a07 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -100,8 +100,8 @@ std::pair coordinates (NR::Point const &v1, NR::Point const &v2, { double det = determinant (v1, v2);; if (fabs (det) < epsilon) { - g_warning ("Vectors do not form a basis.\n"); - return std::make_pair (0.0, 0.0); + // vectors are not linearly independent; we indicate this in the return value(s) + return std::make_pair (HUGE_VAL, HUGE_VAL); } double lambda1 = determinant (w, v2) / det; @@ -113,6 +113,11 @@ std::pair coordinates (NR::Point const &v1, NR::Point const &v2, bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w) { std::pair coords = coordinates (v1, v2, w); + if (coords.first == HUGE_VAL) { + // catch the case that the vectors are not linearly independent + // FIXME: Can we assume that it's safe to return true if the vectors point in different directions? + return (NR::dot (v1, v2) < 0); + } return (coords.first >= 0 and coords.second >= 0); } -- cgit v1.2.3