From e107effc64bc9bcde0aaaa3dea110c233509980a Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Mon, 15 Feb 2010 17:38:48 +0000
Subject: [PATCH] new method projectOntoTangentSpace

[[Imported from SVN: r5570]]
---
 src/unitvector.hh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/unitvector.hh b/src/unitvector.hh
index f1b8186f..ca0dee98 100644
--- a/src/unitvector.hh
+++ b/src/unitvector.hh
@@ -55,7 +55,7 @@ public:
         }
 
         // Project gradient onto the tangent plane at b in order to obtain the surface gradient
-        result.axpy(-1*(b.data_*result), b.data_);
+        result = b.projectOntoTangentSpace(result);
 
         // Gradient must be a tangent vector at b, in other words, orthogonal to it
         assert( std::abs(b.data_ * result) < 1e-7);
@@ -63,6 +63,13 @@ public:
         return result;
     }
 
+    /** \brief Project tangent vector of R^n onto the tangent space */
+    EmbeddedTangentVector projectOntoTangentSpace(const EmbeddedTangentVector& v) const {
+        EmbeddedTangentVector result = v;
+        result.axpy(-1*(data_*result), data_);
+        return result;
+    }
+
     /** \brief The global coordinates, if you really want them */
     const Dune::FieldVector<double,dim>& globalCoordinates() const {
         return data_;
-- 
GitLab