#ifndef CLASSIC_PlanarArcGeometry_HH #define CLASSIC_PlanarArcGeometry_HH // ------------------------------------------------------------------------ // $RCSfile: PlanarArcGeometry.h,v $ // ------------------------------------------------------------------------ // $Revision: 1.1.1.1 $ // ------------------------------------------------------------------------ // Copyright: see Copyright.readme // ------------------------------------------------------------------------ // // Class: PlanarArcGeometry // // ------------------------------------------------------------------------ // Class category: BeamlineGeometry // ------------------------------------------------------------------------ // // $Date: 2000/03/27 09:32:34 $ // $Author: fci $ // // ------------------------------------------------------------------------ #include "BeamlineGeometry/Geometry.h" // Class PlanarArcGeometry // ------------------------------------------------------------------------ /// A simple arc in the XZ plane. // A PlanarArcGeometry object represents a Geometry which is as simple // circular arc in the local XZ plane with no torsion. The origin is // defined at the centre of the geometry, and the geometry extends // from -length/2 to +length/2. Transformations generated by this // geometry are characterised by a displacement in the XZ plane and a // pure Y rotation. // [p] // This geometry can have two states: // [ul] // [li]Length L is non-zero: // The geometry is defined as a finite arc in the XZ plane. // In this state, the following changes are allowed: // [ul] // [li]Setting the angle phi: recompute the curvature as phi / L. // [li]Setting the curvature h: recompute the angle as h * L. // [li]Setting the length: if non-zero, recompute the angle as h * L, // otherwise set h to zero. // [/ul] // [li]Length is zero, implying curvature also zero: // The geometry is defined as sharp bend by phi in the XZ plane. // In this state, the following changes are allowed: // [ul] // [li]Setting the angle phi: leave both h and L as zero. // [li]Setting the curvature h: not accepted. // [li]Setting the length: if non-zero, recompute the angle as h * L. // [/ul] // [/ul] class PlanarArcGeometry : public BGeometryBase { public: /// Constructor. // Build PlanarArcGeometry from length [b]l[/b] and curvature [b]h[/b]. PlanarArcGeometry(double l, double h); /// Constructor. // Build PlanarArcGeometry from length zero and angle [b]phi[/b]. PlanarArcGeometry(double phi); PlanarArcGeometry(const PlanarArcGeometry &); virtual ~PlanarArcGeometry(); const PlanarArcGeometry &operator=(const PlanarArcGeometry &); /// Get arc length. // Return arc length along the design arc. virtual double getArcLength() const; /// Get element length. // Return element length measured along the design arc. virtual double getElementLength() const; /// Get angle. double getBendAngle() const; /// Get curvature. double getCurvature() const; /// Set angle. virtual void setBendAngle(double); /// Set curvature. void setCurvature(double); /// Set length. // Assign the arc length for this class. virtual void setElementLength(double); /// Get origin. // Return the distance from the entrance of the geometry to the origin // (non-negative). virtual double getOrigin() const; /// Get entrance. // Return the arc length from the origin to the entrance of the // geometry (non-positive). double getEntrance() const; /// Get exit. // Return the arc length from the origin to the exit of the // geometry (non-negative). double getExit() const; /// Get transform. // Return the transform of the local coordinate system from the // position [b]fromS[/b] to the position [b]toS[/b]. virtual Euclid3D getTransform(double fromS, double toS) const; /// Get transform. // Equivalent to getTransform(0.0, s). // Return the transform of the local coordinate system from the // origin and [b]s[/b]. virtual Euclid3D getTransform(double s) const; /// Get transform. // Equivalent to getTransform(getEntrance(), getExit()). // Return the transform of the local coordinate system from the // entrance to the exit of the element. virtual Euclid3D getTotalTransform() const; /// Get transform. // Equivalent to getTransform(0.0, getEntrance()). // Return the transform of the local coordinate system from the // origin to the entrance of the element. Euclid3D getEntranceFrame() const; /// Get transform. // Equivalent to getTransform(0.0, getExit()). // Return the transform of the local coordinate system from the // origin to the exit of the element. Euclid3D getExitFrame() const; private: double len; double h; double angle; }; // inlined (trivial) member functions inline PlanarArcGeometry::PlanarArcGeometry(double l, double hh): len(l), h(hh), angle(hh *l) {} inline PlanarArcGeometry::PlanarArcGeometry(double phi): len(0.0), h(0.0), angle(phi) {} inline PlanarArcGeometry::PlanarArcGeometry(const PlanarArcGeometry &rhs): BGeometryBase(rhs),len(rhs.len), h(rhs.h), angle(rhs.angle) {} inline const PlanarArcGeometry &PlanarArcGeometry::operator= (const PlanarArcGeometry &rhs) { len = rhs.len; h = rhs.h; angle = rhs.angle; return *this; } #endif // CLASSIC_PlanarArcGeometry_HH