41 :
Component(name), _is_local(false), geometry_m(NULL) {
51 :
Component(name), _is_local(false), geometry_m(NULL) {
57 :
Component(rhs.getName()), _is_local(false), geometry_m(NULL) {
92 "No field defined for Offset");
97 "No field defined for Offset");
150 if (
fabs(vec1(2)) > 1
e-9 ||
fabs(vec2(2)) > 1
e-9)
152 "Rotations out of midplane are not implemented");
154 double theta =
atan2(vec2(1), vec2(0))-
atan2(vec1(1), vec1(0));
161 double s =
sin(theta);
162 double c =
cos(theta);
171 "Global offset needs a local coordinate system");
173 double length =
sqrt(translation(0)*translation(0)+
174 translation(1)*translation(1)+
175 translation(2)*translation(2));
178 Euclid3D euclid3D(-
sin(theta_in)*length, 0.,
cos(theta_in)*length,
206 for (
int i = 0; i < 3; ++i) {
219 for (
size_t i = 0; i < 3; ++i)
220 if (
fabs(dTranslation(i)) > tol ||
fabs(dRotation(i)) > tol)
226 return !(off1 == off2);
239 "Try to determine if Offset bends when geometry_m not allocated");
242 for (
size_t i = 0; i < 3; ++i)
257 double displacement) {
261 sin(phi_in)*displacement,
276 sin(phi_out)*radius_out,
279 cos(phi_out+theta_out),
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
constexpr double e
The value of .
Interface for basic beam line object.
static double float_tolerance
static Offset localCylindricalOffset(std::string name, double theta_in, double theta_out, double displacement)
Vector_t getEndPosition() const
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
virtual void setName(const std::string &name)
Set element name.
Tps< T > sin(const Tps< T > &x)
Sine.
ElemType getElType() const
returns element type as enumeration needed in the envelope tracker
virtual const std::string & getName() const
Get element name.
virtual void visitOffset(const Offset &)=0
Apply the algorithm to an Offset (placement).
static Offset globalCylindricalOffset(std::string name, double radius_out, double phi_out, double theta_out)
void setEndDirection(Vector_t direction)
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Euclid3DGeometry & getGeometry() override
Get geometry.
constexpr double pi
The value of .
void setElType(ElemType elt)
set the element type as enumeration needed in the envelope tracker
constexpr double c
The velocity of light in m/s.
Displacement and rotation in space.
ElementBase * clone() const override
static Offset globalCartesianOffset(std::string name, Vector_t end_position, Vector_t end_direction)
PartBunchBase< double, 3 > * RefPartBunch_m
Offset & operator=(const Offset &)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Vektor< double, 3 > Vector_t
const Rotation3D & getRotation() const
Get rotation.
static Offset localCartesianOffset(std::string name, Vector_t end_position, Vector_t end_direction)
bool bends() const override
Abstract base class for electromagnetic fields.
Tps< T > sqrt(const Tps< T > &x)
Square root.
bool operator!=(const Offset &off1, const Offset &off2)
Tps< T > cos(const Tps< T > &x)
Cosine.
void setAperture(const ApertureType &type, const std::vector< double > &args)
void updateGeometry(Vector_t startPosition, Vector_t startDirection)
virtual Euclid3D getTotalTransform() const
Get total transform from beginning to end.
Euclid3DGeometry * geometry_m
static const double lengthUnits_m
Vector_t getEndDirection() const
void accept(BeamlineVisitor &) const override
Interface for a single beam element.
std::pair< ElementBase::ApertureType, std::vector< double > > getAperture() const
Rotation in 3-dimensional space.
void setIsLocal(bool isLocal)
static double getTheta(Vector_t vec1, Vector_t vec2)
EMField & getField() override
Not implemented - throws GeneralClassicException.
Vector3D getAxis() const
Get axis vector.
void setEndPosition(Vector_t position)
Inform & endl(Inform &inf)
bool isGeometryAllocated() const
const Vector3D & getVector() const
Get displacement.
bool operator==(const TwoPolynomial &left, const TwoPolynomial &right)
static Vector_t rotate(Vector_t vec, double theta)