Project
Loading...
Searching...
No Matches
FairGeoTransform.cxx
Go to the documentation of this file.
1
/********************************************************************************
2
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3
* *
4
* This software is distributed under the terms of the *
5
* GNU Lesser General Public Licence (LGPL) version 3, *
6
* copied verbatim in the file "LICENSE" *
7
********************************************************************************/
8
//*-- AUTHOR : Ilse Koenig
9
//*-- Modified : 16/06/1999
10
//*-- Modified : 21/06/2005 D.Bertini
11
13
//
14
// FairGeoTransform
15
//
16
// Class to hold the orientation (rotation matrix) and the position
17
// (translation vector) of a coordinate system (system 2) relative to a
18
// reference coordinate system (system 1)
19
// It provides member functions to transform a vector or a point and an other
20
// coordinate system from its own coordinate system into the reference
21
// coordinate system and vice versa.
22
// Instances of this class can e.g. hold the lab or detector transformation of
23
// a geometry volume (see class FairGeoVolume)
24
//
25
// Inline functions:
26
//
27
// FairGeoTransform()
28
// The default constructor creates an identity transformation
29
// FairGeoTransform(FairGeoTransform& t)
30
// copy constructor
31
// void setTransform(const FairGeoTransform& t)
32
// copies the given transformation
33
// void setRotMatrix(const FairGeoRotation& r)
34
// copies the given rotation matrix
35
// void setRotMatrix(const Double_t* a)
36
// creates a rotation matrix taking an Double_t array with 9 components
37
// void setTransVector(const FairGeoVector& t)
38
// copies the given translation vector
39
// void setTransVector(const Double_t* a)
40
// creates a translation vector taking an Double_t array with 6 components
41
// const FairGeoRotation& getRotMatrix() const
42
// returns the rotation matrix
43
// const FairGeoVector& getTransVector() const
44
// returns the translation vector
45
//
47
48
#include "
FairGeoTransform.h
"
49
50
//#include <iostream>
51
//#include <iomanip>
52
//#include "math.h"
53
54
ClassImp
(
FairGeoTransform
);
55
56
FairGeoTransform::FairGeoTransform
()
57
:
TObject
()
58
, rot(
FairGeoRotation
(0, 0, 0))
59
, trans(
FairGeoVector
(0, 0, 0))
60
, trans_cm(
FairGeoVector
(0, 0, 0))
61
{}
62
63
FairGeoTransform
&
FairGeoTransform::operator=
(
const
FairGeoTransform
& t)
64
{
65
rot
= t.
getRotMatrix
();
66
trans
= t.
getTransVector
();
67
68
return
*
this
;
69
}
70
71
FairGeoVector
FairGeoTransform::transFrom
(
const
FairGeoVector
& p)
const
72
{
73
// Transforms a vector (point) given in its own coordinate
74
// system (2) into the reference coordinate system (1)
75
// e.g. v2 is a vector (point) in the detector coordinate system;
76
// it can be transformed to a vector v2 the lab system with
77
// FairGeoVector v2=mo.transFrom(v1)
78
// where mo is the coordinate system of the mother
79
return
rot
* p +
trans
;
80
}
81
82
FairGeoVector
FairGeoTransform::transTo
(
const
FairGeoVector
& p)
const
83
{
84
// Transforms a vector (point) given in the reference system (1)
85
// into the local coordinate system (2)
86
// e.g. v1 is a vector (point) in the lab system; it can be transformed to
87
// a vector v2 the detector coordinate system with
88
// FairGeoVector v2=mo.transTo(v1)
89
// where mo is the coordinate system of the mother
90
return
rot
.
inverse
() * (p -
trans
);
91
}
92
93
void
FairGeoTransform::transTo
(
const
FairGeoTransform
& s)
94
{
95
// Transforms the coordinate system into the coordinate system
96
// described by s. Both transformations must have the same reference
97
// system e.g. the lab system
98
// This function is e.g. used to transform a daughter coordinate system
99
// with a transformation relative to the lab into the detector coordinate
100
// system.
101
const
FairGeoRotation
& rm = s.getRotMatrix();
102
FairGeoRotation
rt(rm.
inverse
());
103
if
(rm.
diff2
(
rot
) < 0.000001) {
104
rot
.
setUnitMatrix
();
105
}
else
{
106
rot
.
transform
(rt);
107
}
108
trans
-= s.getTransVector();
109
trans
= rt *
trans
;
110
// trans.round(3); // rounds to 3 digits (precision 1 micrometer)
111
}
112
113
void
FairGeoTransform::transFrom
(
const
FairGeoTransform
& s)
114
{
115
// Transforms the coordinate system described by s into the local
116
// coordinate system
117
// This function is e.g. used to transform a daughter coordinate system
118
// with a transformation relative to its mother into the lab system.
119
// e.g. daughterDetTransform.transFrom(motherLabTransform)
120
const
FairGeoRotation
&
r
= s.getRotMatrix();
121
rot
.
transform
(
r
);
122
trans
=
r
*
trans
;
123
trans
+= s.getTransVector();
124
}
125
126
void
FairGeoTransform::clear
()
127
{
128
trans
.
clear
();
129
rot
.
setUnitMatrix
();
130
}
131
132
void
FairGeoTransform::print
()
133
{
134
rot
.
print
();
135
trans
.
print
();
136
}
137
138
void
FairGeoTransform::invert
(
void
)
139
{
140
rot
.
invert
();
141
trans
=
rot
*
trans
;
142
trans
*= -1.;
143
}
ClassImp
ClassImp(FairGeoTransform)
FairGeoTransform.h
FairGeoRotation
Definition
FairGeoRotation.h:24
FairGeoRotation::invert
FairGeoRotation & invert()
Definition
FairGeoRotation.h:196
FairGeoRotation::inverse
FairGeoRotation inverse() const
Definition
FairGeoRotation.h:185
FairGeoRotation::transform
FairGeoRotation & transform(const FairGeoRotation &)
Definition
FairGeoRotation.h:175
FairGeoRotation::setUnitMatrix
void setUnitMatrix()
Definition
FairGeoRotation.h:204
FairGeoRotation::print
void print() const
Definition
FairGeoRotation.h:217
FairGeoRotation::diff2
Double_t diff2(const FairGeoRotation &) const
Definition
FairGeoRotation.cxx:110
FairGeoTransform
Definition
FairGeoTransform.h:21
FairGeoTransform::trans
FairGeoVector trans
Definition
FairGeoTransform.h:24
FairGeoTransform::FairGeoTransform
FairGeoTransform()
Definition
FairGeoTransform.cxx:56
FairGeoTransform::getTransVector
const FairGeoVector & getTransVector() const
Definition
FairGeoTransform.h:33
FairGeoTransform::getRotMatrix
const FairGeoRotation & getRotMatrix() const
Definition
FairGeoTransform.h:32
FairGeoTransform::invert
void invert(void)
Definition
FairGeoTransform.cxx:138
FairGeoTransform::rot
FairGeoRotation rot
Definition
FairGeoTransform.h:23
FairGeoTransform::transTo
FairGeoVector transTo(const FairGeoVector &p) const
Definition
FairGeoTransform.cxx:82
FairGeoTransform::print
void print()
Definition
FairGeoTransform.cxx:132
FairGeoTransform::transFrom
FairGeoVector transFrom(const FairGeoVector &p) const
Definition
FairGeoTransform.cxx:71
FairGeoTransform::clear
void clear()
Definition
FairGeoTransform.cxx:126
FairGeoTransform::operator=
FairGeoTransform & operator=(const FairGeoTransform &t)
Definition
FairGeoTransform.cxx:63
FairGeoVector
Definition
FairGeoVector.h:20
FairGeoVector::clear
void clear()
Definition
FairGeoVector.h:97
FairGeoVector::print
void print() const
Definition
FairGeoVector.h:98
TObject
unsigned char
Detectors
3rdparty
FairRootBase
src
FairGeoTransform.cxx
Generated on Sat Nov 7 2026 19:53:07 for Project by
1.9.8