BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTiltOffset.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSTiltOffset.hh"
20#include "BDSUtilities.hh"
21
22#include "globals.hh"
23#include "G4RotationMatrix.hh"
24#include "G4ThreeVector.hh"
25#include "G4Transform3D.hh"
26
27#include <ostream>
28
29BDSTiltOffset::BDSTiltOffset():
30 dx(0.0), dy(0.0), tilt(0.0)
31{;}
32
33BDSTiltOffset::BDSTiltOffset(G4double xOffset,
34 G4double yOffset,
35 G4double tiltIn):
36 dx(xOffset), dy(yOffset), tilt(tiltIn)
37{;}
38
39std::ostream& operator<< (std::ostream& out, BDSTiltOffset const &to)
40{
41 out << to.tilt << " " << to.dx << " " << to.dy;
42 return out;
43}
44
45G4Transform3D BDSTiltOffset::Transform3D() const
46{
47 G4ThreeVector off = GetOffset();
48 G4RotationMatrix rm = G4RotationMatrix();
49 rm.rotateZ(tilt);
50 return G4Transform3D(rm, off);
51}
52
54{
55 return BDS::IsFinite(dx) || BDS::IsFinite(dy);
56}
57
59{
60 return BDS::IsFinite(tilt);
61}
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
G4double dx
Horizontal displacement (mm) - note right handed coordinate system.
G4double tilt
Tilt angle (rad) - rotation angle about Z axis.
G4bool HasFiniteTilt() const
Inspector.
G4double dy
Vertical displacement (mm)
G4bool HasFiniteOffset() const
Inspector.
G4Transform3D Transform3D() const
Get a transform to represent this tilt offset.
G4ThreeVector GetOffset() const
More advance accessor for offset - only in x,y.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())