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) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSTiltOffset.hh"
19#include "BDSUtilities.hh"
20
21#include "globals.hh"
22#include "G4RotationMatrix.hh"
23#include "G4ThreeVector.hh"
24#include "G4Transform3D.hh"
25
26#include <ostream>
27
28BDSTiltOffset::BDSTiltOffset():
29 dx(0.0), dy(0.0), tilt(0.0)
30{;}
31
32BDSTiltOffset::BDSTiltOffset(G4double xOffset,
33 G4double yOffset,
34 G4double tiltIn):
35 dx(xOffset), dy(yOffset), tilt(tiltIn)
36{;}
37
38std::ostream& operator<< (std::ostream& out, BDSTiltOffset const &to)
39{
40 out << to.tilt << " " << to.dx << " " << to.dy;
41 return out;
42}
43
44G4Transform3D BDSTiltOffset::Transform3D() const
45{
46 G4ThreeVector off = GetOffset();
47 G4RotationMatrix rm = G4RotationMatrix();
48 rm.rotateZ(tilt);
49 return G4Transform3D(rm, off);
50}
51
53{
54 return BDS::IsFinite(dx) || BDS::IsFinite(dy);
55}
56
58{
59 return BDS::IsFinite(tilt);
60}
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())