18#include "BDSExtent.hh"
19#include "BDSParticleCoords.hh"
20#include "BDSTiltOffset.hh"
21#include "BDSUtilities.hh"
24#include "G4ThreeVector.hh"
25#include "G4TwoVector.hh"
43 const std::pair<G4double, G4double>& extYIn,
44 const std::pair<G4double, G4double>& extZIn):
45 extXNeg(extXIn.first),
46 extXPos(extXIn.second),
47 extYNeg(extYIn.first),
48 extYPos(extYIn.second),
49 extZNeg(extZIn.first),
50 extZPos(extZIn.second)
54 G4double extYNegIn, G4double extYPosIn,
55 G4double extZNegIn, G4double extZPosIn):
65 extXNeg(-
std::abs(extXIn)),
66 extXPos(
std::abs(extXIn)),
67 extYNeg(-
std::abs(extYIn)),
68 extYPos(
std::abs(extYIn)),
69 extZNeg(-
std::abs(extZIn)),
70 extZPos(
std::abs(extZIn))
74 BDSExtent(extIn.x(), extIn.y(), extIn.z())
78 G4ThreeVector extInPos):
79 extXNeg(extInNeg.x()),
80 extXPos(extInPos.x()),
81 extYNeg(extInNeg.y()),
82 extYPos(extInPos.y()),
83 extZNeg(extInNeg.z()),
87BDSExtent::~BDSExtent()
92 std::vector<G4ThreeVector> result;
132 topRight.rotate(angle);
133 botRight.rotate(angle);
134 botLeft.rotate(angle);
135 topLeft.rotate(angle);
137 G4double xMin = std::min({botRight.x(), botLeft.x(), topLeft.x(), topRight.x()});
138 G4double xMax = std::max({botRight.x(), botLeft.x(), topLeft.x(), topRight.x()});
139 G4double yMin = std::min({botRight.y(), botLeft.y(), topLeft.y(), topRight.y()});
140 G4double yMax = std::max({botRight.y(), botLeft.y(), topLeft.y(), topRight.y()});
148std::ostream& operator<< (std::ostream& out,
BDSExtent const& ext)
186 return std::hypot(x, y);
194 return xOK && yOK && zOK;
200 G4bool result =
false;
201 for (
const auto& p : otherPoints)
208 G4ThreeVector point(coords.x, coords.y, coords.z);
214 margin = std::abs(margin);
251 std::max(first.
XPos(), second.
XPos()),
252 std::min(first.
YNeg(), second.
YNeg()),
253 std::max(first.
YPos(), second.
YPos()),
254 std::min(first.
ZNeg(), second.
ZNeg()),
255 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())