Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garsoft
Pandora
GArPandora
RotationTransformation.cxx
Go to the documentation of this file.
1
#include "
RotationTransformation.h
"
2
3
#include <algorithm>
4
#include <cmath>
5
#include <limits>
6
7
#include "
messagefacility/MessageLogger/MessageLogger.h
"
8
9
namespace
gar
{
10
namespace
gar_pandora {
11
12
const
int
RotationTransformation::kAxisX
= 0;
13
const
int
RotationTransformation::kAxisY
= 1;
14
const
int
RotationTransformation::kAxisZ
= 2;
15
16
//------------------------------------------------------------------------------------------------------------------------------------------
17
18
RotationTransformation::RotationTransformation
(
int
axis,
float
angle)
19
: m_RotationSet(false),
20
m_RotationAngle(angle *
CLHEP
::
pi
/180.)
21
{
22
switch
(axis)
23
{
24
case
kAxisX
:
25
this->
SetRotationX
();
26
MF_LOG_INFO
(
"RotationTransformation"
)
27
<<
"Rotation set around the x axis with angle "
<<
m_RotationAngle
<<
" rad"
;
28
m_RotationSet
=
true
;
29
break
;
30
case
kAxisY
:
31
this->
SetRotationY
();
32
MF_LOG_INFO
(
"RotationTransformation"
)
33
<<
"Rotation set around the y axis with angle "
<<
m_RotationAngle
<<
" rad"
;
34
m_RotationSet
=
true
;
35
break
;
36
case
kAxisZ
:
37
this->
SetRotationZ
();
38
MF_LOG_INFO
(
"RotationTransformation"
)
39
<<
"Rotation set around the z axis with angle "
<<
m_RotationAngle
<<
" rad"
;
40
m_RotationSet
=
true
;
41
break
;
42
default
:
43
throw
;
44
break
;
45
}
46
}
47
48
//------------------------------------------------------------------------------------------------------------------------------------------
49
50
RotationTransformation::~RotationTransformation
() {}
51
52
//------------------------------------------------------------------------------------------------------------------------------------------
53
54
const
pandora::CartesianVector
RotationTransformation::MakeRotation
(
const
pandora::CartesianVector &initialVec)
const
55
{
56
if
(
m_RotationSet
) {
57
return
pandora::CartesianVector( initialVec.GetX() *
fRotMatrix
[0] + initialVec.GetY() *
fRotMatrix
[3] + initialVec.GetZ() *
fRotMatrix
[6], initialVec.GetX() *
fRotMatrix
[1] + initialVec.GetY() *
fRotMatrix
[4] + initialVec.GetZ() *
fRotMatrix
[7], initialVec.GetX() *
fRotMatrix
[2] + initialVec.GetY() *
fRotMatrix
[5] + initialVec.GetZ() *
fRotMatrix
[8] );
58
}
else
{
59
MF_LOG_INFO
(
"RotationTransformation"
)
60
<<
"No rotation axis was defined - operation aborted!"
;
61
return
pandora::CartesianVector(initialVec.GetX(), initialVec.GetY(), initialVec.GetZ());
62
}
63
}
64
65
//------------------------------------------------------------------------------------------------------------------------------------------
66
67
void
RotationTransformation::SetRotationX
()
68
{
69
//col x
70
fRotMatrix
[0] = 1.;
71
fRotMatrix
[1] = 0.;
72
fRotMatrix
[2] = 0.;
73
74
//col y
75
fRotMatrix
[3] = 0.;
76
fRotMatrix
[4] = std::cos(
m_RotationAngle
);
77
fRotMatrix
[5] = std::sin(
m_RotationAngle
);
78
79
//col z
80
fRotMatrix
[6] = 0.;
81
fRotMatrix
[7] = -std::sin(
m_RotationAngle
);
82
fRotMatrix
[8] = std::cos(
m_RotationAngle
);
83
}
84
85
//------------------------------------------------------------------------------------------------------------------------------------------
86
87
void
RotationTransformation::SetRotationY
()
88
{
89
//col x
90
fRotMatrix
[0] = std::cos(
m_RotationAngle
);
91
fRotMatrix
[1] = 0.;
92
fRotMatrix
[2] = -std::sin(
m_RotationAngle
);
93
94
//col y
95
fRotMatrix
[3] = 0.;
96
fRotMatrix
[4] = 1.;
97
fRotMatrix
[5] = 0.;
98
99
//col z
100
fRotMatrix
[6] = std::sin(
m_RotationAngle
);
101
fRotMatrix
[7] = 0.;
102
fRotMatrix
[8] = std::cos(
m_RotationAngle
);
103
}
104
105
//------------------------------------------------------------------------------------------------------------------------------------------
106
107
void
RotationTransformation::SetRotationZ
()
108
{
109
//col x
110
fRotMatrix
[0] = std::cos(
m_RotationAngle
);
111
fRotMatrix
[1] = std::sin(
m_RotationAngle
);
112
fRotMatrix
[2] = 0.;
113
114
//col y
115
fRotMatrix
[3] = -std::sin(
m_RotationAngle
);
116
fRotMatrix
[4] = std::cos(
m_RotationAngle
);
117
fRotMatrix
[5] = 0.;
118
119
//col z
120
fRotMatrix
[6] = 0.;
121
fRotMatrix
[7] = 0.;
122
fRotMatrix
[8] = 1.;
123
}
124
}
125
}
gar::gar_pandora::RotationTransformation::~RotationTransformation
virtual ~RotationTransformation()
Definition:
RotationTransformation.cxx:50
RotationTransformation.h
gar::gar_pandora::RotationTransformation::kAxisZ
static const int kAxisZ
Definition:
RotationTransformation.h:22
gar::gar_pandora::RotationTransformation::RotationTransformation
RotationTransformation(int kAxis, float angle)
Definition:
RotationTransformation.cxx:18
gar::gar_pandora::RotationTransformation::kAxisX
static const int kAxisX
Definition:
RotationTransformation.h:20
gar::gar_pandora::RotationTransformation::SetRotationZ
void SetRotationZ()
Definition:
RotationTransformation.cxx:107
MessageLogger.h
CLHEP
Definition:
RandomNumberGenerator.h:144
gar::gar_pandora::RotationTransformation::kAxisY
static const int kAxisY
Definition:
RotationTransformation.h:21
gar::gar_pandora::RotationTransformation::SetRotationX
void SetRotationX()
Definition:
RotationTransformation.cxx:67
gar::gar_pandora::RotationTransformation::m_RotationSet
bool m_RotationSet
Definition:
RotationTransformation.h:28
MF_LOG_INFO
#define MF_LOG_INFO(category)
Definition:
MessageLogger.h:225
gar::gar_pandora::RotationTransformation::MakeRotation
const pandora::CartesianVector MakeRotation(const pandora::CartesianVector &initialVec) const
Definition:
RotationTransformation.cxx:54
gar
General GArSoft Utilities.
Definition:
anatest_module.cc:57
gar::gar_pandora::RotationTransformation::m_RotationAngle
float m_RotationAngle
Definition:
RotationTransformation.h:29
wirecell.units.pi
float pi
Definition:
units.py:11
gar::gar_pandora::RotationTransformation::fRotMatrix
float fRotMatrix[9]
Definition:
RotationTransformation.h:30
gar::gar_pandora::RotationTransformation::SetRotationY
void SetRotationY()
Definition:
RotationTransformation.cxx:87
Generated by
1.8.11