From 3353c00c6ec8ffbfb8109d87d0bf260a8f6e32f5 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Thu, 18 Feb 2010 17:11:25 +0000
Subject: [PATCH] barf if derivative of distance is requested for two conjugate
 points.  The derivative doesn't exist in that case

[[Imported from SVN: r5589]]
---
 src/unitvector.hh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/unitvector.hh b/src/unitvector.hh
index 6ca22338..c6c1d757 100644
--- a/src/unitvector.hh
+++ b/src/unitvector.hh
@@ -64,6 +64,8 @@ public:
 
         if (x > 1-eps) {  // regular expression is unstable, use the series expansion instead
             result *= -2 + 2*(x-1)/3 - 4/15*(x-1)*(x-1) + 4/35*(x-1)*(x-1)*(x-1);
+        } else if (x < -1+eps) {  // a and b are conjugate.  The function is not differentiable
+            DUNE_THROW(Dune::Exception, "Distance is not differentiable for conjugate points!");
         } else {
             result *= -2*std::acos(x) / std::sqrt(1-x*x);
         }
-- 
GitLab