43 :
Component(rhs.getName()), _is_local(false), geometry_m(nullptr) {
77 "No field defined for Offset");
82 "No field defined for Offset");
137 "Rotations out of midplane are not implemented");
159 "Global offset needs a local coordinate system");
163 double length =
std::sqrt(translation(0) * translation(0) +
164 translation(1) * translation(1) +
165 translation(2) * translation(2));
181 double thetaIn =
std::atan2(-startDirection[0], startDirection[1]);
185 double thetaRel = thetaOut-thetaIn;
208 for (
int i = 0; i < 3; ++i) {
221 for (
size_t i = 0; i < 3; ++i)
228 return !(off1 == off2);
241 "Try to determine if Offset bends when geometry_m not allocated");
244 for (
size_t i = 0; i < 3; ++i)
259 double displacement) {
bool operator!=(const Offset &off1, const Offset &off2)
Return not of operator ==.
bool operator==(const Offset &off1, const Offset &off2)
Return true if off1 is equal to off2 within static floating point tolerance.
std::ostream & operator<<(std::ostream &out, const Offset &off)
Print Offset off1 to the ostream.
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Inform & endl(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
virtual void visitOffset(const Offset &)=0
Apply the algorithm to an offset (placement).
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
virtual void setName(const std::string &name)
Set element name.
virtual const std::string & getName() const
Get element name.
void setAperture(const ApertureType &type, const std::vector< double > &args)
std::pair< ApertureType, std::vector< double > > getAperture() const
static Vector_t rotate(Vector_t vec, double theta)
Rotate vec anticlockwise by angle theta about z axis; return the rotated vector.
static Offset globalCylindricalOffset(const std::string &name, double radius_out, double phi_out, double theta_out)
Factory method to make an offset in global cylindrical polar coordinates.
static double getTheta(Vector_t vec1, Vector_t vec2)
Calculate the angle between vectors on the midplane.
void updateGeometry(Vector_t startPosition, Vector_t startDirection)
Convert to a local coordinate system for global offsets.
Euclid3DGeometry & getGeometry() override
Get geometry.
Offset & operator=(const Offset &)
Assignment operator deep copies geometry and wrappedGeometry; all other stuff is copied as well.
bool isGeometryAllocated() const
~Offset()
deletes geometry and wrappedGeometry
void setEndPosition(Vector_t position)
Vector_t getEndPosition() const
EMField & getField() override
Not implemented - throws GeneralClassicException.
Offset()
Default constructor sets everything to 0., makes a default geometry with everything set to 0.
void setEndDirection(Vector_t direction)
static double float_tolerance
ElementBase * clone() const override
Just calls the copy constructor on *this.
void accept(BeamlineVisitor &) const override
Apply visitor to Offset.
Euclid3DGeometry * geometry_m
static Offset localCartesianOffset(const std::string &name, Vector_t end_position, Vector_t end_direction)
Factory method to make an offset in cartesian coordinates local to the end of the previous element.
static Offset globalCartesianOffset(const std::string &name, Vector_t end_position, Vector_t end_direction)
Factory method to make an offset in global cartesian coordinates.
bool getIsLocal() const
Returns true if stored coordinates are in the local coordinate system of the last placed object.
void setIsLocal(bool isLocal)
Set to true if stored coordinates are in the local coordinate system of the last placed object.
bool bends() const override
Returns true if either input angle or output angle are greater than float_tolerance.
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Vector_t getEndDirection() const
static Offset localCylindricalOffset(const std::string &name, double theta_in, double theta_out, double displacement)
Factory method to make an offset in Cylindrical coordinates local to the end of the previous element.
Displacement and rotation in space.
const Vector3D & getVector() const
Get displacement.
const Rotation3D & getRotation() const
Get rotation.
virtual Euclid3D getTotalTransform() const
Get total transform from beginning to end.
Rotation in 3-dimensional space.
Vector3D getAxis() const
Get axis vector.
Abstract base class for electromagnetic fields.
Vektor< double, 3 > Vector_t