ATLAS Offline Software
graphics
VP1
VP1HEPVis
src
SbRotation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/*
6
* VP1HEPVis
7
* SbRotation.cxx
8
*
9
* Created on: Dec 13, 2012
10
* Author: rbianchi <Riccardo.Maria.Bianchi@cern.ch>
11
*
12
*/
13
14
15
/*
16
*
17
* New file for HEPVis
18
*
19
* taken from: http://fossies.org/dox/osc_vis_source_16.11.6/HEPVis_2include_2HEPVis_2SbRotation_8cxx_source.html
20
*
21
* R.M. Bianchi <rbianchi@cern.ch>
22
*
23
* 12.12.2012
24
*
25
*===================
26
* VP1 Customization:
27
*
28
* - look into the code for comments "// VP1 change [...] //---"
29
*
30
*/
31
32
//---
33
34
35
36
37
// this :
38
// VP1 change
39
#include <
VP1HEPVis/SbRotation.h
>
40
//---
41
42
#include <math.h>
43
44
#include <Inventor/SbVec3d.h>
45
46
HEPVis::SbRotation::SbRotation
()
47
//NOTE : the default HEPVis::SbRotation() corresponds to a unit matrix.
48
//WARNING : Inventor/SbRotation()::quad is not initialized !
49
// So that the HEPVis::SbRotation() does not the same than
50
// the Inventor::SbRotation().
51
:m_quat(0,0,0,1)
52
{
53
}
54
55
HEPVis::SbRotation::SbRotation
(
const
SbVec3d&
axis
,
double
radians) {
56
//FIXME : if(axis.length()==0) //throw
57
m_quat[3] =
::cos
(radians/2);
58
double
sineval =
::sin
(radians/2);
59
SbVec3d
a
=
axis
;
60
a
.normalize();
61
m_quat[0] =
a
[0] * sineval;
62
m_quat[1] =
a
[1] * sineval;
63
m_quat[2] =
a
[2] * sineval;
64
}
65
66
// from SbRotation& SbRotation::setValue(const SbMatrix & m)
67
68
HEPVis::SbRotation::SbRotation
(
69
double
a11,
double
a12,
double
a13,
double
a14
70
,
double
a21,
double
a22,
double
a23,
double
a24
71
,
double
a31,
double
a32,
double
a33,
double
a34
72
,
double
a41,
double
a42,
double
a43,
double
a44
73
) {
74
75
double
m
[4][4] = { { a11, a12, a13, a14 },
76
{ a21, a22, a23, a24 },
77
{ a31, a32, a33, a34 },
78
{ a41, a42, a43, a44 } };
79
80
double
scalerow =
m
[0][0] +
m
[1][1] +
m
[2][2];
81
82
if
(scalerow > 0.0) {
83
double
s
= ::sqrt(scalerow +
m
[3][3]);
84
m_quat[3] =
s
* 0.5;
85
s
= 0.5 /
s
;
86
87
m_quat[0] = (
m
[1][2] -
m
[2][1]) *
s
;
88
m_quat[1] = (
m
[2][0] -
m
[0][2]) *
s
;
89
m_quat[2] = (
m
[0][1] -
m
[1][0]) *
s
;
90
}
91
else
{
92
int
i
= 0;
93
if
(
m
[1][1] >
m
[0][0])
i
= 1;
94
if
(
m
[2][2] >
m
[
i
][
i
])
i
= 2;
95
96
int
j = (
i
+1)%3;
97
int
k
= (j+1)%3;
98
99
double
s
= ::sqrt((
m
[
i
][
i
] - (
m
[j][j] +
m
[
k
][
k
])) +
m
[3][3]);
100
101
m_quat[
i
] =
s
* 0.5;
102
s
= 0.5 /
s
;
103
104
m_quat[3] = (
m
[j][
k
] -
m
[
k
][j]) *
s
;
105
m_quat[j] = (
m
[
i
][j] +
m
[j][
i
]) *
s
;
106
m_quat[
k
] = (
m
[
i
][
k
] +
m
[
k
][
i
]) *
s
;
107
}
108
109
if
(
m
[3][3] != 1.0) {
110
m_quat *= (1.0/::sqrt(
m
[3][3]));
111
}
112
}
113
114
//HEPVis::SbRotation& HEPVis::SbRotation::operator*=(const double s){
115
// m_quat *= s;
116
// return *this;
117
//}
118
119
void
HEPVis::SbRotation::multVec
(
const
SbVec3d&
src
,SbVec3d& dst)
const
{
120
//SbMatrix mat;
121
//mat.setRotate(*this);
122
123
double
x
= m_quat[0];
124
double
y
= m_quat[1];
125
double
z
= m_quat[2];
126
double
w
= m_quat[3];
127
128
double
matrix
[4][4];
129
matrix
[0][0] =
w
*
w
+
x
*
x
-
y
*
y
-
z
*
z
;
130
matrix
[0][1] = 2*
x
*
y
+ 2*
w
*
z
;
131
matrix
[0][2] = 2*
x
*
z
- 2*
w
*
y
;
132
matrix
[0][3] = 0;
133
134
matrix
[1][0] = 2*
x
*
y
-2*
w
*
z
;
135
matrix
[1][1] =
w
*
w
-
x
*
x
+
y
*
y
-
z
*
z
;
136
matrix
[1][2] = 2*
y
*
z
+ 2*
w
*
x
;
137
matrix
[1][3] = 0;
138
139
matrix
[2][0] = 2*
x
*
z
+ 2*
w
*
y
;
140
matrix
[2][1] = 2*
y
*
z
- 2*
w
*
x
;
141
matrix
[2][2] =
w
*
w
-
x
*
x
-
y
*
y
+
z
*
z
;
142
matrix
[2][3] = 0;
143
144
matrix
[3][0] = 0;
145
matrix
[3][1] = 0;
146
matrix
[3][2] = 0;
147
matrix
[3][3] =
w
*
w
+
x
*
x
+
y
*
y
+
z
*
z
;
148
149
//mat.multVecMatrix(src, dst);
150
//if(SbMatrixP::isIdentity(this->matrix)) { dst = src; return; }
151
152
double
* t0 =
matrix
[0];
153
double
*
t1
=
matrix
[1];
154
double
*
t2
=
matrix
[2];
155
double
*
t3
=
matrix
[3];
156
157
SbVec3d
s
=
src
;
158
159
double
W
=
s
[0]*t0[3] +
s
[1]*
t1
[3] +
s
[2]*
t2
[3] +
t3
[3];
160
161
dst[0] = (
s
[0]*t0[0] +
s
[1]*
t1
[0] +
s
[2]*
t2
[0] +
t3
[0])/
W
;
162
dst[1] = (
s
[0]*t0[1] +
s
[1]*
t1
[1] +
s
[2]*
t2
[1] +
t3
[1])/
W
;
163
dst[2] = (
s
[0]*t0[2] +
s
[1]*
t1
[2] +
s
[2]*
t2
[2] +
t3
[2])/
W
;
164
}
165
166
167
python.SystemOfUnits.s
int s
Definition:
SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition:
SystemOfUnits.py:91
WriteCellNoiseToCool.src
src
Definition:
WriteCellNoiseToCool.py:513
JetTiledMap::W
@ W
Definition:
TiledEtaPhiMap.h:44
LUCID_EventTPCnv_Dict::t3
std::vector< LUCID_RawData_p1 > t3
Definition:
LUCID_EventTPCnvDict.h:28
yodamerge_tmp.axis
list axis
Definition:
yodamerge_tmp.py:241
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition:
ALFA_EventTPCnvDict.h:43
drawFromPickle.cos
cos
Definition:
drawFromPickle.py:36
x
#define x
HEPVis::SbRotation::SbRotation
SbRotation()
Definition:
SbRotation.cxx:46
lumiFormat.i
int i
Definition:
lumiFormat.py:85
z
#define z
SbRotation.h
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition:
ALFA_EventTPCnvDict.h:44
python.testIfMatch.matrix
matrix
Definition:
testIfMatch.py:66
a
TList * a
Definition:
liststreamerinfos.cxx:10
y
#define y
drawFromPickle.sin
sin
Definition:
drawFromPickle.py:36
python.IoTestsLib.w
def w
Definition:
IoTestsLib.py:200
HEPVis::SbRotation::multVec
void multVec(const SbVec3d &src, SbVec3d &dst) const
Definition:
SbRotation.cxx:119
fitman.k
k
Definition:
fitman.py:528
Generated on Mon Dec 23 2024 21:17:42 for ATLAS Offline Software by
1.8.18