19#include "BDSExtent.hh"
20#include "BDSParticleCoords.hh"
21#include "BDSTiltOffset.hh"
22#include "BDSUtilities.hh"
25#include "G4ThreeVector.hh"
26#include "G4TwoVector.hh"
44 const std::pair<G4double, G4double>& extYIn,
45 const std::pair<G4double, G4double>& extZIn):
46 extXNeg(extXIn.first),
47 extXPos(extXIn.second),
48 extYNeg(extYIn.first),
49 extYPos(extYIn.second),
50 extZNeg(extZIn.first),
51 extZPos(extZIn.second)
55 G4double extYNegIn, G4double extYPosIn,
56 G4double extZNegIn, G4double extZPosIn):
66 extXNeg(-std::abs(extXIn)),
67 extXPos( std::abs(extXIn)),
68 extYNeg(-std::abs(extYIn)),
69 extYPos( std::abs(extYIn)),
70 extZNeg(-std::abs(extZIn)),
71 extZPos( std::abs(extZIn))
75 BDSExtent(extIn.x(), extIn.y(), extIn.z())
79 G4ThreeVector extInPos):
80 extXNeg(extInNeg.x()),
81 extXPos(extInPos.x()),
82 extYNeg(extInNeg.y()),
83 extYPos(extInPos.y()),
84 extZNeg(extInNeg.z()),
88BDSExtent::~BDSExtent()
93 std::vector<G4ThreeVector> result;
133 topRight.rotate(angle);
134 botRight.rotate(angle);
135 botLeft.rotate(angle);
136 topLeft.rotate(angle);
138 G4double xMin = std::min({botRight.x(), botLeft.x(), topLeft.x(), topRight.x()});
139 G4double xMax = std::max({botRight.x(), botLeft.x(), topLeft.x(), topRight.x()});
140 G4double yMin = std::min({botRight.y(), botLeft.y(), topLeft.y(), topRight.y()});
141 G4double yMax = std::max({botRight.y(), botLeft.y(), topLeft.y(), topRight.y()});
149std::ostream& operator<< (std::ostream& out,
BDSExtent const& ext)
187 return std::hypot(x, y);
195 return xOK && yOK && zOK;
201 G4bool result =
false;
202 for (
const auto& p : otherPoints)
209 G4ThreeVector point(coords.x, coords.y, coords.z);
215 margin = std::abs(margin);
252 std::max(first.
XPos(), second.
XPos()),
253 std::min(first.
YNeg(), second.
YNeg()),
254 std::max(first.
YPos(), second.
YPos()),
255 std::min(first.
ZNeg(), second.
ZNeg()),
256 std::max(first.
ZPos(), second.
ZPos()));
Holder for +- extents in 3 dimensions.
G4double XPos() const
Accessor.
BDSExtent Tilted(G4double angle) const
Provide a new copy of this extent but rotated along Z by a given tilt angle.
BDSExtent Translate(const G4ThreeVector &offset) const
Provide a new copy of this extent with an offset applied.
std::vector< G4ThreeVector > AllBoundaryPoints() const
All 8 boundary points of the bounding box.
BDSExtent()
Default constructor gives 0 in all extents - typically unphysical.
G4double ZPos() const
Accessor.
G4double MaximumAbsTransverse() const
Return the maximum absolute value considering only x,y.
BDSExtent ExpandBy(G4double margin) const
Return a copy expanded in all dimensions by the given margin.
G4bool Encompasses(const G4ThreeVector &point) const
Return whether the extent encompasses the point. True if point lies inside the extent.
G4double MaximumAbs() const
Return the maximum absolute value considering all dimensions.
void ExpandToEncompass(const BDSExtent &other)
G4double XNeg() const
Accessor.
G4double YNeg() const
Accessor.
BDSExtent TiltOffset(const BDSTiltOffset *tiltOffset) const
Provide a new copy of this extent with both a tilt and an offset applied.
G4double MinimumAbsTransverse() const
Return the minimum absolute value considering only x,y.
G4double MinimumAbs() const
Return the minimum absolute value considering all dimensions.
BDSExtent ExpandTransverselyBy(G4double margin) const
Return a copy expanded in x and y by the given margin.
G4double YPos() const
Accessor.
G4double ZNeg() const
Accessor.
G4double TransverseBoundingRadius() const
Return a radius that would encompass the maximum x,y extent.
A set of particle coordinates.
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
G4double GetTilt() const
Accessor.
G4ThreeVector GetOffset() const
More advance accessor for offset - only in x,y.
Return either G4Tubs or G4CutTubs depending on flat face.
BDSExtent MaximumCombinedExtent(const BDSExtent &first, const BDSExtent &second)
Returns the extent which is the greatest extent in all six directions.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())