OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
AffineTransformation.h
Go to the documentation of this file.
1 #ifndef MSLANG_AFFINETRANSFORMATION_H
2 #define MSLANG_AFFINETRANSFORMATION_H
3 
4 #include "Algorithms/Vektor.h"
5 #include "AppTypes/Tenzor.h"
6 
7 #include <iostream>
8 #include <fstream>
9 
10 namespace mslang {
11  struct AffineTransformation: public Tenzor<double, 3> {
13  const Vector_t& row1):
14  Tenzor(row0[0], row0[1], row0[2], row1[0], row1[1], row1[2], 0.0, 0.0, 1.0) {
15  }
16 
18  Tenzor(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) { }
19 
22  double det = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
23 
24  Ret(0, 0) = (*this)(1, 1) / det;
25  Ret(1, 0) = -(*this)(1, 0) / det;
26  Ret(0, 1) = -(*this)(0, 1) / det;
27  Ret(1, 1) = (*this)(0, 0) / det;
28 
29  Ret(0, 2) = - Ret(0, 0) * (*this)(0, 2) - Ret(0, 1) * (*this)(1, 2);
30  Ret(1, 2) = - Ret(1, 0) * (*this)(0, 2) - Ret(1, 1) * (*this)(1, 2);
31  Ret(2, 2) = 1.0;
32 
33  return Ret;
34  }
35 
36  Vector_t getOrigin() const {
37  return Vector_t(-(*this)(0, 2), -(*this)(1, 2), 0.0);
38  }
39 
40  double getAngle() const {
41  return atan2((*this)(1, 0), (*this)(0, 0));
42  }
43 
44  Vector_t transformTo(const Vector_t &v) const {
45  const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3>* >(this);
46  Vector_t b(v[0], v[1], 1.0);
47  Vector_t w = dot(A, b);
48 
49  return Vector_t(w[0], w[1], 0.0);
50  }
51 
52  Vector_t transformFrom(const Vector_t &v) const {
54  return inv.transformTo(v);
55  }
56 
59  const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3> *>(this);
60  const Tenzor<double, 3> &BTenz = *static_cast<const Tenzor<double, 3> *>(&B);
61  Tenzor<double, 3> &C = *static_cast<Tenzor<double, 3> *>(&Ret);
62 
63  C = dot(A, BTenz);
64 
65  return Ret;
66  }
67  };
68 }
69 
70 #endif
T det(const AntiSymTenzor< T, 3 > &t)
AffineTransformation(const Vector_t &row0, const Vector_t &row1)
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
Vector_t transformFrom(const Vector_t &v) const
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
Vector_t transformTo(const Vector_t &v) const
AffineTransformation getInverse() const
AffineTransformation mult(const AffineTransformation &B)