48 :
Component(name), _is_local(false), geometry_m(nullptr) {
54 :
Component(rhs.getName()), _is_local(false), geometry_m(nullptr) {
144 if (std::abs(vec1(2)) > 1
e-9 || std::abs(vec2(2)) > 1
e-9)
146 "Offset::getTheta(...)",
"Rotations out of midplane are not implemented");
148 double theta = std::atan2(vec2(1), vec2(0)) - std::atan2(vec1(1), vec1(0));
155 double s = std::sin(theta);
156 double c = std::cos(theta);
163 "Offset::updateGeometry(...)",
"Global offset needs a local coordinate system");
165 double length = std::sqrt(
166 translation(0) * translation(0) + translation(1) * translation(1)
167 + translation(2) * translation(2));
171 -std::sin(theta_in) * length, 0., std::cos(theta_in) * length, 0., -theta_out, 0.);
198 for (
int i = 0; i < 3; ++i) {
210 for (
size_t i = 0; i < 3; ++i)
211 if (std::abs(dTranslation(i)) > tol || std::abs(dRotation(i)) > tol)
217 return !(off1 == off2);
230 "Offset::bends",
"Try to determine if Offset bends when geometry_m not allocated");
233 for (
size_t i = 0; i < 3; ++i)
245 std::string name,
double phi_in,
double phi_out,
double displacement) {
249 {std::cos(phi_in) * displacement, std::sin(phi_in) * displacement, 0.}));
258 std::string name,
double radius_out,
double phi_out,
double theta_out) {
262 Vector_t<double, 3>({std::cos(phi_out) * radius_out, std::sin(phi_out) * radius_out, 0.}));
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.
Inform & endl(Inform &inf)
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.
PartBunch_t * 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
Vector_t< double, 3 > getEndDirection() const
Euclid3DGeometry & getGeometry() override
Get geometry.
void setEndDirection(Vector_t< double, 3 > direction)
Offset & operator=(const Offset &)
Assignment operator deep copies geometry and wrappedGeometry; all other stuff is copied as well.
static Offset localCylindricalOffset(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.
bool isGeometryAllocated() const
static Vector_t< double, 3 > rotate(Vector_t< double, 3 > vec, double theta)
Rotate vec anticlockwise by angle theta about z axis; return the rotated vector.
Vector_t< double, 3 > _end_position
static Offset globalCartesianOffset(std::string name, Vector_t< double, 3 > end_position, Vector_t< double, 3 > end_direction)
Factory method to make an offset in global cartesian coordinates.
~Offset()
deletes geometry and wrappedGeometry
Vector_t< double, 3 > _end_direction
static const double lengthUnits_m
EMField & getField() override
Not implemented - throws GeneralClassicException.
Offset()
Default constructor sets everything to 0., makes a default geometry with everything set to 0.
static double getTheta(Vector_t< double, 3 > vec1, Vector_t< double, 3 > vec2)
Calculate the angle between vectors on the midplane.
static double float_tolerance
void initialise(PartBunch_t *bunch, double &startField, double &endField) override
static Offset localCartesianOffset(std::string name, Vector_t< double, 3 > end_position, Vector_t< double, 3 > end_direction)
Factory method to make an offset in cartesian coordinates local to the end of the previous element.
void setEndPosition(Vector_t< double, 3 > position)
ElementBase * clone() const override
Just calls the copy constructor on *this.
void accept(BeamlineVisitor &) const override
Apply visitor to Offset.
static Offset globalCylindricalOffset(std::string name, double radius_out, double phi_out, double theta_out)
Factory method to make an offset in global cylindrical polar coordinates.
Vector_t< double, 3 > getEndPosition() const
Euclid3DGeometry * geometry_m
bool getIsLocal() const
Returns true if stored coordinates are in the local coordinate system of the last placed object.
void updateGeometry(Vector_t< double, 3 > startPosition, Vector_t< double, 3 > startDirection)
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.
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.