Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 7b1a9193 authored by Sadr Mohsen's avatar Sadr Mohsen Committed by Sadr Mohsen
Browse files

Removing Tenzor

parent 49d756a3
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,18 @@ extern Inform *gmsg;
CoordinateSystemTrafo::CoordinateSystemTrafo():
origin_m(0.0),
orientation_m(1.0, 0.0, 0.0, 0.0),
rotationMatrix_m(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
{ }
rotationMatrix_m(3,3)
{
rotationMatrix_m(0,0) = 1.0;
rotationMatrix_m(0,1) = 0.0;
rotationMatrix_m(0,2) = 0.0;
rotationMatrix_m(1,0) = 0.0;
rotationMatrix_m(1,1) = 1.0;
rotationMatrix_m(1,2) = 0.0;
rotationMatrix_m(2,0) = 0.0;
rotationMatrix_m(2,1) = 0.0;
rotationMatrix_m(2,2) = 1.0;
}
CoordinateSystemTrafo::CoordinateSystemTrafo(const CoordinateSystemTrafo &right):
origin_m(right.origin_m),
......@@ -25,7 +35,8 @@ CoordinateSystemTrafo::CoordinateSystemTrafo(const Vector_t &origin,
void CoordinateSystemTrafo::invert() {
origin_m = -orientation_m.rotate(origin_m);
orientation_m = orientation_m.conjugate();
rotationMatrix_m = transpose(rotationMatrix_m);
//rotationMatrix_m = transpose(rotationMatrix_m);
rotationMatrix_m = boost::numeric::ublas::trans(rotationMatrix_m);
}
CoordinateSystemTrafo CoordinateSystemTrafo::operator*(const CoordinateSystemTrafo &right) const {
......@@ -40,4 +51,4 @@ void CoordinateSystemTrafo::operator*=(const CoordinateSystemTrafo &right) {
orientation_m *= right.orientation_m;
orientation_m.normalize();
rotationMatrix_m = orientation_m.getRotationMatrix();
}
\ No newline at end of file
}
......@@ -3,7 +3,9 @@
#include "Algorithms/Vektor.h"
#include "Algorithms/Quaternion.h"
#include "AppTypes/Tenzor.h"
//#include "AppTypes/Tenzor.h"
//#include "Algorithms/Matrix.h"
#include <boost/numeric/ublas/matrix.hpp>
class CoordinateSystemTrafo {
public:
......@@ -34,7 +36,9 @@ public:
private:
Vector_t origin_m;
Quaternion orientation_m;
Tenzor<double, 3> rotationMatrix_m;
// Tenzor<double, 3> rotationMatrix_m;
//matrix_t rotationMatrix_m(3,3);
matrix_t rotationMatrix_m;
};
inline
......@@ -74,24 +78,85 @@ CoordinateSystemTrafo CoordinateSystemTrafo::inverted() const {
return result;
}
inline
Vector_t CoordinateSystemTrafo::transformTo(const Vector_t &r) const {
return dot(rotationMatrix_m, r - origin_m);
inline Vector_t CoordinateSystemTrafo::transformTo(const Vector_t& r) const {
std::array<double, 3> tempArray;
std::copy(&(r-origin_m)[0], &(r-origin_m)[0] + 3, tempArray.begin());
boost::numeric::ublas::vector<double> boost_r_m_origin(3);
std::copy(tempArray.begin(), tempArray.end(), boost_r_m_origin.begin());
boost::numeric::ublas::vector<double> result = boost::numeric::ublas::prod(rotationMatrix_m, boost_r_m_origin);
Vector_t transformedVector(result(0), result(1), result(2)); // Convert boost::numeric::ublas::vector to Vector_t
return transformedVector;
}
inline
Vector_t CoordinateSystemTrafo::transformFrom(const Vector_t &r) const {
return dot(transpose(rotationMatrix_m), r) + origin_m;
inline Vector_t CoordinateSystemTrafo::transformFrom(const Vector_t& r) const {
std::array<double, 3> tempArray;
//std::copy(r, r + 3, tempArray.begin());
for (size_t i = 0; i < 3; ++i) {
tempArray[i] = r[i];
}
boost::numeric::ublas::vector<double> boost_r(3);
for (size_t i = 0; i < 3; ++i) {
boost_r[i] = tempArray[i];
}
//boost::numeric::ublas::vector<double> boost_r(3);
//std::copy(tempArray.begin(), tempArray.end(), boost_r.begin());
boost::numeric::ublas::vector<double> result = boost::numeric::ublas::prod(boost::numeric::ublas::trans(rotationMatrix_m), boost_r);
Vector_t transformedVector(result(0), result(1), result(2)); // Convert boost::numeric::ublas::vector to Vector_t
return transformedVector + origin_m;
}
inline
Vector_t CoordinateSystemTrafo::rotateTo(const Vector_t &r) const {
return dot(rotationMatrix_m, r);
inline Vector_t CoordinateSystemTrafo::rotateTo(const Vector_t& r) const {
std::array<double, 3> tempArray;
//std::copy(&r, &r + 3, tempArray.begin());
for (size_t i = 0; i < 3; ++i) {
tempArray[i] = r[i];
}
boost::numeric::ublas::vector<double> boost_r(3);
for (size_t i = 0; i < 3; ++i) {
boost_r[i] = tempArray[i];
}
//boost::numeric::ublas::vector<double> boost_r(3);
//std::copy(tempArray.begin(), tempArray.end(), boost_r.begin());
boost::numeric::ublas::vector<double> result = boost::numeric::ublas::prod(rotationMatrix_m, boost_r);
Vector_t rotatedVector(result(0), result(1), result(2)); // Convert boost::numeric::ublas::vector to Vector_t
return rotatedVector;
}
inline
Vector_t CoordinateSystemTrafo::rotateFrom(const Vector_t &r) const {
return dot(transpose(rotationMatrix_m), r);
inline Vector_t CoordinateSystemTrafo::rotateFrom(const Vector_t& r) const {
std::array<double, 3> tempArray;
//std::copy(&r, &r + 3, tempArray.begin());
for (size_t i = 0; i < 3; ++i) {
tempArray[i] = r[i];
}
boost::numeric::ublas::vector<double> boost_r(3);
for (size_t i = 0; i < 3; ++i) {
boost_r[i] = tempArray[i];
}
//boost::numeric::ublas::vector<double> boost_r(3);
//std::copy(tempArray.begin(), tempArray.end(), boost_r.begin());
boost::numeric::ublas::vector<double> result = boost::numeric::ublas::prod(boost::numeric::ublas::trans(rotationMatrix_m), boost_r);
Vector_t rotatedVector(result(0), result(1), result(2)); // Convert boost::numeric::ublas::vector to Vector_t
return rotatedVector;
}
#endif
\ No newline at end of file
#endif
#include "Algorithms/Quaternion.h"
#include "AppTypes/Tenzor.h"
#include "Physics/Physics.h"
#include "Utility/RandomNumberGen.h"
#include "Utilities/GeneralClassicException.h"
......@@ -19,7 +18,8 @@ namespace {
}
}
Quaternion::Quaternion(const Tenzor<double, 3> &M):
//Quaternion::Quaternion(const Tenzor<double, 3> &M):
Quaternion::Quaternion(const matrix_t &M):
Vektor<double, 4>(0.0)
{
(*this)(0) = std::sqrt(std::max(0.0, 1 + M(0, 0) + M(1, 1) + M(2, 2))) / 2;
......@@ -132,19 +132,33 @@ Vector_t Quaternion::rotate(const Vector_t & vec) const
return ((*this) * (quat * (*this).conjugate())).imag();
}
Tenzor<double, 3> Quaternion::getRotationMatrix() const
//Tenzor<double, 3> Quaternion::getRotationMatrix() const
//matrix_t getRotationMatrix() const
boost::numeric::ublas::matrix<double> Quaternion::getRotationMatrix() const
{
Quaternion rot(*this);
rot.normalize();
Tenzor<double, 3> mat(1 - 2 * (rot(2) * rot(2) + rot(3) * rot(3)),
2 * (-rot(0) * rot(3) + rot(1) * rot(2)),
2 * (rot(0) * rot(2) + rot(1) * rot(3)),
2 * (rot(0) * rot(3) + rot(1) * rot(2)),
1 - 2 * (rot(1) * rot(1) + rot(3) * rot(3)),
2 * (-rot(0) * rot(1) + rot(2) * rot(3)),
2 * (-rot(0) * rot(2) + rot(1) * rot(3)),
2 * (rot(0) * rot(1) + rot(2) * rot(3)),
1 - 2 * (rot(1) * rot(1) + rot(2) * rot(2)));
matrix_t mat(3, 3);
mat(0, 0) = 1 - 2 * (rot(2) * rot(2) + rot(3) * rot(3));
mat(0, 1) = 2 * (-rot(0) * rot(3) + rot(1) * rot(2));
mat(0, 2) = 2 * (rot(0) * rot(2) + rot(1) * rot(3));
mat(1, 0) = 2 * (rot(0) * rot(3) + rot(1) * rot(2));
mat(1, 1) = 1 - 2 * (rot(1) * rot(1) + rot(3) * rot(3));
mat(1, 2) = 2 * (-rot(0) * rot(1) + rot(2) * rot(3));
mat(2, 0) = 2 * (-rot(0) * rot(2) + rot(1) * rot(3));
mat(2, 1) = 2 * (rot(0) * rot(1) + rot(2) * rot(3));
mat(2, 2) = 1 - 2 * (rot(1) * rot(1) + rot(2) * rot(2));
//Tenzor<double, 3> mat(1 - 2 * (rot(2) * rot(2) + rot(3) * rot(3)),
// 2 * (-rot(0) * rot(3) + rot(1) * rot(2)),
// 2 * (rot(0) * rot(2) + rot(1) * rot(3)),
// 2 * (rot(0) * rot(3) + rot(1) * rot(2)),
// 1 - 2 * (rot(1) * rot(1) + rot(3) * rot(3)),
// 2 * (-rot(0) * rot(1) + rot(2) * rot(3)),
// 2 * (-rot(0) * rot(2) + rot(1) * rot(3)),
// 2 * (rot(0) * rot(1) + rot(2) * rot(3)),
// 1 - 2 * (rot(1) * rot(1) + rot(2) * rot(2)));
return mat;
}
\ No newline at end of file
}
......@@ -3,9 +3,10 @@
#include "AppTypes/Vektor.h"
#include "Algorithms/Vektor.h"
#include "Algorithms/Matrix.h"
template <class, unsigned>
class Tenzor;
//template <class, unsigned>
//class Tenzor;
class Quaternion: public Vektor<double, 4> {
public:
......@@ -14,7 +15,8 @@ public:
Quaternion(const double &, const double &, const double &, const double &);
Quaternion(const Vector_t &);
Quaternion(const double &, const Vector_t &);
Quaternion(const Tenzor<double, 3> &);
//Quaternion(const Tenzor<double, 3> &);
Quaternion(const matrix_t &);
Quaternion operator*(const double &) const;
Quaternion operator*(const Quaternion &) const;
......@@ -38,7 +40,9 @@ public:
Vector_t rotate(const Vector_t &) const;
Tenzor<double, 3> getRotationMatrix() const;
//Tenzor<double, 3> getRotationMatrix() const;
//matrix_t getRotationMatrix() const;
boost::numeric::ublas::matrix<double> getRotationMatrix() const;
};
typedef Quaternion Quaternion_t;
......@@ -124,4 +128,4 @@ Vector_t Quaternion::imag() const
}
#endif
\ No newline at end of file
#endif
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