OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
AffineTransformation.h
Go to the documentation of this file.
1 #ifndef MSLANG_AFFINETRANSFORMATION_H
2 #define MSLANG_AFFINETRANSFORMATION_H
3 
5 #include "Algorithms/Vektor.h"
6 
7 #include <iostream>
8 #include <fstream>
9 
10 namespace mslang {
11  struct AffineTransformation: public matrix_t {
13  const Vector_t& row1):
14  matrix_t(3,3){
15  (*this)(0, 0) = row0[0];
16  (*this)(0, 1) = row0[1];
17  (*this)(0, 2) = row0[2];
18  (*this)(1, 0) = row1[0];
19  (*this)(1, 1) = row1[1];
20  (*this)(1, 2) = row1[2];
21  (*this)(2, 0) = 0.0;
22  (*this)(2, 1) = 0.0;
23  (*this)(2, 2) = 1.0;
24  }
25 
27  matrix_t(3,3){
28  (*this)(0, 0) = 1.0;
29  (*this)(0, 1) = 0.0;
30  (*this)(0, 2) = 0.0;
31  (*this)(1, 0) = 0.0;
32  (*this)(1, 1) = 1.0;
33  (*this)(1, 2) = 0.0;
34  (*this)(2, 0) = 0.0;
35  (*this)(2, 1) = 0.0;
36  (*this)(2, 2) = 1.0;
37  }
38 
41  double det = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
42 
43  Ret(0, 0) = (*this)(1, 1) / det;
44  Ret(1, 0) = -(*this)(1, 0) / det;
45  Ret(0, 1) = -(*this)(0, 1) / det;
46  Ret(1, 1) = (*this)(0, 0) / det;
47 
48  Ret(0, 2) = - Ret(0, 0) * (*this)(0, 2) - Ret(0, 1) * (*this)(1, 2);
49  Ret(1, 2) = - Ret(1, 0) * (*this)(0, 2) - Ret(1, 1) * (*this)(1, 2);
50  Ret(2, 2) = 1.0;
51 
52  return Ret;
53  }
54 
55  Vector_t getOrigin() const {
56  return Vector_t(-(*this)(0, 2), -(*this)(1, 2), 0.0);
57  }
58 
59  double getAngle() const {
60  return atan2((*this)(1, 0), (*this)(0, 0));
61  }
62 
63  Vector_t transformTo(const Vector_t &v) const {
64  matrix_t b = matrix_t(3, 1); // Create a 3x1 matrix for b
65  b(0, 0) = v(0);
66  b(1, 0) = v(1);
67  b(2, 0) = 1.0;
69  return Vector_t(w(0, 0), w(1, 0), 0.0);
70  }
71 
72  Vector_t transformFrom(const Vector_t &v) const {
74  return inv.transformTo(v);
75  }
76 
79  matrix_t &A = *this;
80  const matrix_t &BTenz = B;
81  matrix_t &C = Ret;
82  C = boost::numeric::ublas::prod(A, BTenz);
83  return Ret;
84  }
85  };
86 }
87 
88 #endif
boost::numeric::ublas::matrix< double > matrix_t
Definition: BoostMatrix.h:23
T det(const AntiSymTenzor< T, 3 > &)
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
AffineTransformation mult(const AffineTransformation &B)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Vector_t transformTo(const Vector_t &v) const
T::PETE_Expr_t::PETE_Return_t prod(const PETE_Expr< T > &expr)
Definition: PETE.h:1121
AffineTransformation(const Vector_t &row0, const Vector_t &row1)
Vector_t transformFrom(const Vector_t &v) const
AffineTransformation getInverse() const