From 874cb377da4a1149946e9028d9dd701e75ff0302 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Thu, 5 Dec 2013 14:04:24 +0000
Subject: [PATCH] Do not normalize unitvectors / unit quaternions in
 constructors and operator=

This effectively means that we use another prolongation of the distance
function on M into the surrounding space.  Since the prolongation does not
matter this patch should not change the algorithm behavior.  However, it
shaves off a few norm calculations and division.  I cannot really measure
any difference though.

A possible effect of this is that while all values should remain on the
manifold, they may start to 'drift away' due to numerical artifacts.
So we may have to add an occasional renormalization step eventually.

[[Imported from SVN: r9558]]
---
 dune/gfe/rotation.hh   |  6 +-----
 dune/gfe/unitvector.hh | 10 +++-------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/dune/gfe/rotation.hh b/dune/gfe/rotation.hh
index 055de5ff..8396bf31 100644
--- a/dune/gfe/rotation.hh
+++ b/dune/gfe/rotation.hh
@@ -187,15 +187,11 @@ public:
     {
         for (int i=0; i<4; i++)
             (*this)[i] = c[i];
-
-        *this /= this->two_norm();
     }
 
     explicit Rotation<T,3>(const Dune::FieldVector<T,4>& c)
         : Quaternion<T>(c)
-    {
-        *this /= this->two_norm();
-    }
+    {}
 
     Rotation<T,3>(Dune::FieldVector<T,3> axis, T angle)
     {
diff --git a/dune/gfe/unitvector.hh b/dune/gfe/unitvector.hh
index a64902d1..3e3bf8ef 100644
--- a/dune/gfe/unitvector.hh
+++ b/dune/gfe/unitvector.hh
@@ -89,19 +89,16 @@ public:
     UnitVector()
     {}
 
-    /** \brief Constructor from a vector.  The vector gets normalized */
+    /** \brief Constructor from a vector.  The vector does not get normalized! */
     UnitVector(const Dune::FieldVector<T,N>& vector)
         : data_(vector)
-    {
-        data_ /= data_.two_norm();
-    }
+    {}
 
-    /** \brief Constructor from an array.  The array gets normalized */
+    /** \brief Constructor from an array.  The array does not get normalized! */
     UnitVector(const Dune::array<T,N>& vector)
     {
         for (int i=0; i<N; i++)
             data_[i] = vector[i];
-        data_ /= data_.two_norm();
     }
 
     /** \brief Assigment from UnitVector with different type -- used for automatic differentiation with ADOL-C */
@@ -124,7 +121,6 @@ public:
     UnitVector<T,N>& operator=(const Dune::FieldVector<T,N>& vector)
     {
         data_ = vector;
-        data_ /= data_.two_norm();
         return *this;
     }
 
-- 
GitLab