144 if (std::abs(vec1(2)) > 1e-9 || std::abs(vec2(2)) > 1e-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)
bool operator==(const Offset &off1, const Offset &off2)
std::ostream & operator<<(std::ostream &out, const Offset &off)
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
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.
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
ElementBase(const std::string &name)
Constructor with given name.
Vector_t< double, 3 > getEndDirection() const
Euclid3DGeometry & getGeometry() override
Get geometry.
void setEndDirection(Vector_t< double, 3 > direction)
Offset & operator=(const Offset &)
static Offset localCylindricalOffset(std::string name, double theta_in, double theta_out, double displacement)
bool isGeometryAllocated() const
static Vector_t< double, 3 > rotate(Vector_t< double, 3 > vec, double theta)
Vector_t< double, 3 > _end_position
static Offset globalCartesianOffset(std::string name, Vector_t< double, 3 > end_position, Vector_t< double, 3 > end_direction)
Vector_t< double, 3 > _end_direction
static const double lengthUnits_m
EMField & getField() override
Not implemented - throws GeneralClassicException.
static double getTheta(Vector_t< double, 3 > vec1, Vector_t< double, 3 > vec2)
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)
Offset(const std::string &name)
void setEndPosition(Vector_t< double, 3 > position)
ElementBase * clone() const override
void accept(BeamlineVisitor &) const override
static Offset globalCylindricalOffset(std::string name, double radius_out, double phi_out, double theta_out)
Vector_t< double, 3 > getEndPosition() const
Euclid3DGeometry * geometry_m
void updateGeometry(Vector_t< double, 3 > startPosition, Vector_t< double, 3 > startDirection)
void setIsLocal(bool isLocal)
bool bends() const override
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.