Skip to content
Snippets Groups Projects
Commit 5b63350b authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Revert patch 9558

We normalize unit vectors again in the constructor and the assignment operator.
This makes sure we never drift away from the unit sphere, and it also allows
us to init unit spheres with any value in R^n and be sure we obtain a unit
vector.  This makes the test pass again.  Leaving the projection out didn't
really make a measurable difference anyway.

[[Imported from SVN: r9574]]
parent 0a5c98f6
No related branches found
No related tags found
No related merge requests found
...@@ -196,11 +196,15 @@ public: ...@@ -196,11 +196,15 @@ public:
{ {
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
(*this)[i] = c[i]; (*this)[i] = c[i];
*this /= this->two_norm();
} }
explicit Rotation<T,3>(const Dune::FieldVector<T,4>& c) explicit Rotation<T,3>(const Dune::FieldVector<T,4>& c)
: Quaternion<T>(c) : Quaternion<T>(c)
{} {
*this /= this->two_norm();
}
Rotation<T,3>(Dune::FieldVector<T,3> axis, T angle) Rotation<T,3>(Dune::FieldVector<T,3> axis, T angle)
{ {
......
...@@ -89,16 +89,19 @@ public: ...@@ -89,16 +89,19 @@ public:
UnitVector() 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) UnitVector(const Dune::FieldVector<T,N>& vector)
: data_(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) UnitVector(const Dune::array<T,N>& vector)
{ {
for (int i=0; i<N; i++) for (int i=0; i<N; i++)
data_[i] = vector[i]; data_[i] = vector[i];
data_ /= data_.two_norm();
} }
/** \brief Assigment from UnitVector with different type -- used for automatic differentiation with ADOL-C */ /** \brief Assigment from UnitVector with different type -- used for automatic differentiation with ADOL-C */
...@@ -121,6 +124,7 @@ public: ...@@ -121,6 +124,7 @@ public:
UnitVector<T,N>& operator=(const Dune::FieldVector<T,N>& vector) UnitVector<T,N>& operator=(const Dune::FieldVector<T,N>& vector)
{ {
data_ = vector; data_ = vector;
data_ /= data_.two_norm();
return *this; return *this;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment