Jpp
17.3.0-rc.2
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JGeometry3D
JGeometry3D.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "TRandom3.h"
6
7
#include "
JTools/JQuantile.hh
"
8
#include "
JGeometry3D/JPosition3D.hh
"
9
#include "
JGeometry3D/JAngle3D.hh
"
10
#include "
JGeometry3D/JRotation3D.hh
"
11
#include "
JGeometry3D/JQuaternion3D.hh
"
12
#include "
JMath/JMathToolkit.hh
"
13
#include "
JMath/JConstants.hh
"
14
15
#include "
Jeep/JPrint.hh
"
16
#include "
Jeep/JParser.hh
"
17
#include "
Jeep/JMessage.hh
"
18
19
20
/**
21
* \file
22
*
23
* Example program to test rotations in 3D.
24
* \author mdejong
25
*/
26
int
main
(
int
argc,
char
**argv)
27
{
28
using namespace
std;
29
30
int
numberOfEvents;
31
double
precision;
32
UInt_t seed;
33
int
debug
;
34
35
try
{
36
37
JParser<>
zap(
"Example program to test rotations in 3D."
);
38
39
zap[
'n'
] =
make_field
(numberOfEvents);
40
zap[
'e'
] =
make_field
(precision) = 1.0e-12;
41
zap[
'S'
] =
make_field
(seed) = 0;
42
zap[
'd'
] =
make_field
(
debug
) = 1;
43
44
zap(argc, argv);
45
}
46
catch
(
const
exception &error) {
47
FATAL
(error.what() << endl);
48
}
49
50
gRandom->SetSeed(seed);
51
52
using namespace
JPP;
53
54
55
JQuantile
Q
(
"Distance"
);
56
57
const
JVector3D
v
[] = { JVector3D(1,0,0),
// unit vector along x-axis
58
JVector3D(0,1,0),
// unit vector along y-axis
59
JVector3D(0,0,1) };
// unit vector along z-axis
60
61
for
(
int
i = 0; i != numberOfEvents; ++i) {
62
63
STATUS
(
"event: "
<< setw(10) << i <<
'\r'
);
DEBUG
(endl);
64
65
const
double
theta = gRandom->Uniform(0.0,
PI
);
66
const
double
phi = gRandom->Uniform(0.0, 2*
PI
);
67
68
const
JAngle3D dir(theta, phi);
// principal direction
69
const
JRotation3D
R
(dir);
70
71
//const JRotation3Y Ry(theta); // rotation around y-axis
72
//const JRotation3Z Rz(phi); // rotation around z-axis
73
74
//const JQuaternion3D Ry(theta, JVersor3D(0,1,0)); // rotation around y-axis
75
//const JQuaternion3D Rz(phi, JVersor3D(0,0,1)); // rotation around z-axis
76
77
const
JQuaternion3X Rx(0.0);
// rotation around x-axis
78
const
JQuaternion3Y Ry(theta);
// rotation around y-axis
79
const
JQuaternion3Z Rz(phi);
// rotation around z-axis
80
81
//const JQuaternion3D Rs = Rz * Ry;
82
JQuaternion3D Rs(Rx, Ry, Rz);
83
/*
84
Rs.setIdentity();
85
Rs *= Rz;
86
Rs *= Ry;
87
*/
88
for
(
int
j
= 0;
j
!=
sizeof
(
v
)/
sizeof
(
v
[0]); ++
j
) {
89
90
JPosition3D
A
(
v
[
j
]);
91
JPosition3D B(A);
92
93
//B.rotate(Ry); // rotates around y-axis
94
//B.rotate(Rz); // rotates around z-axis
95
B.rotate(Rs);
96
97
B.rotate(R);
// rotates principal direction to z-axis
98
99
100
Q.put((B - A).getLength());
101
102
if
((B - A).getLengthSquared() > precision*precision) {
103
104
DEBUG
(
"theta "
<< theta << endl);
105
DEBUG
(
"phi "
<< phi << endl);
106
107
//DEBUG("Ry" << endl << Ry);
108
//DEBUG("Rz" << endl << Rz);
109
110
DEBUG
(
"R "
<< endl << R);
111
112
ERROR
(
"A "
<<
FIXED
(7,3) << A.getX() <<
' '
<< A.getY() <<
' '
<< A.getZ() << endl);
113
ERROR
(
"B "
<<
FIXED
(7,3) << B.getX() <<
' '
<< B.getY() <<
' '
<< B.getZ() << endl);
114
}
115
}
116
}
117
STATUS
(endl);
118
119
Q.print(cout);
120
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1517
Q
Q(UTCMax_s-UTCMin_s)-livetime_s
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JMathToolkit.hh
Auxiliary methods for geometrical methods.
STATUS
#define STATUS(A)
Definition:
JMessage.hh:63
JRotation3D.hh
FIXED
Auxiliary data structure for floating point format specification.
Definition:
JManip.hh:446
JPosition3D.hh
JAngle3D.hh
JQuaternion3D.hh
JPrint.hh
I/O formatting auxiliaries.
JConstants.hh
Mathematical constants.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1993
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
JMATH::PI
static const double PI
Mathematical constants.
Definition:
JMath/JConstants.hh:20
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
R
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition:
JDataQuality.sh:41
JParser.hh
Utility class to parse command line options.
JQuantile.hh
JTOOLS::j
int j
Definition:
JPolint.hh:703
JTOOLS::v
data_type v[N+1][M+1]
Definition:
JPolint.hh:777
A
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
Definition:
JShellParser.csh:15
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5