diff --git a/dune/gfe/rotation.hh b/dune/gfe/rotation.hh index 78494e84c17a3c0f9cd15ef79d3908171d1e0902..24536405688a04b1c60a0de29c4c41912cb4041f 100644 --- a/dune/gfe/rotation.hh +++ b/dune/gfe/rotation.hh @@ -196,11 +196,15 @@ 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 3e3bf8ef51545dc70bef6982d73475a46377e2bc..a218ee404a7296dfc8d82b36c4f7bd178ad71420 100644 --- a/dune/gfe/unitvector.hh +++ b/dune/gfe/unitvector.hh @@ -89,16 +89,19 @@ public: UnitVector() {} - /** \brief Constructor from a vector. The vector does not get normalized! */ + /** \brief Constructor from a vector. The vector gets normalized! */ UnitVector(const Dune::FieldVector<T,N>& vector) : data_(vector) - {} + { + data_ /= data_.two_norm(); + } - /** \brief Constructor from an array. The array does not get normalized! */ + /** \brief Constructor from an array. The array gets 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 */ @@ -121,6 +124,7 @@ public: UnitVector<T,N>& operator=(const Dune::FieldVector<T,N>& vector) { data_ = vector; + data_ /= data_.two_norm(); return *this; }