77 "No field defined for Offset");
82 "No field defined for Offset");
135 if (std::abs(vec1(2)) > 1e-9 || std::abs(vec2(2)) > 1e-9) {
137 "Rotations out of midplane are not implemented");
141 double theta = std::atan2(vec2(1), vec2(0)) - std::atan2(vec1(1), vec1(0));
149 double s = std::sin(theta);
150 double c = std::cos(theta);
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));
168 Euclid3D euclid3D(-std::sin(theta_in) * length, 0., std::cos(theta_in) * length,
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)
222 if (std::abs(dTranslation(i)) > tol || std::abs(dRotation(i)) > tol)
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) {
262 std::cos(phi_in)*displacement,
276 std::sin(phi_out)*radius_out,
279 std::cos(phi_out+theta_out),
bool operator!=(const Offset &off1, const Offset &off2)
bool operator==(const Offset &off1, const Offset &off2)
std::ostream & operator<<(std::ostream &out, const Offset &off)
constexpr double c
The velocity of light in m/s.
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double pi
The value of.
virtual void visitOffset(const Offset &)=0
Apply the algorithm to an offset (placement).
Component(const std::string &name)
Constructor with given name.
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
ElementBase(const std::string &name)
Constructor with given name.
static Vector_t rotate(Vector_t vec, double theta)
static Offset globalCylindricalOffset(const std::string &name, double radius_out, double phi_out, double theta_out)
static double getTheta(Vector_t vec1, Vector_t vec2)
void updateGeometry(Vector_t startPosition, Vector_t startDirection)
Euclid3DGeometry & getGeometry() override
Get geometry.
Offset & operator=(const Offset &)
bool isGeometryAllocated() const
void setEndPosition(Vector_t position)
Vector_t getEndPosition() const
EMField & getField() override
Not implemented - throws GeneralClassicException.
void setEndDirection(Vector_t direction)
static double float_tolerance
Offset(const std::string &name)
ElementBase * clone() const override
void accept(BeamlineVisitor &) const override
Euclid3DGeometry * geometry_m
static Offset localCartesianOffset(const std::string &name, Vector_t end_position, Vector_t end_direction)
static Offset globalCartesianOffset(const std::string &name, Vector_t end_position, Vector_t end_direction)
void setIsLocal(bool isLocal)
bool bends() const override
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)
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