// SpacePath.h #ifndef SpacePath_H #define SpacePath_H // Describes a differential path element vector ds in Cartesian, // cylindrical or spherical coordinates. It is constructed using a // subclass and then elements can be fetched for any of these coordinate // systems. The stored vector can also include scalar quantities. // Typical applications include velocity ds/dt and direction ds/d|s|. // // Transformations (translations, rotations, etc) are not provided. // It is expected these will be carried out by external functions which // return new SpacePath objects. // // Three orthogonal coordinate systems are: // Cartesian: (x, y, z) // Cylindrical: (rxy, phi, z) // Spherical: (rxyz, theta, phi) . // These coordinates may be obtained via the space point interface. // // The correponding path element vectors are: // Cartesian: (dx, dy, dz) // Cylindrical: (drxy, rxy*dphi, dz) // Spherical: (drxyz, rxyz*dtheta, rxy*dphi) . // These elements may be accessed via the usual space vector interface // (v_x(), v_y(), ...) or via the methods defined here. #include "SpacePointVector.h" class SpacePath : public SpacePointVector { public: // methods // Default constructor. SpacePath( ); // Constructor from a space point. SpacePath( const SpacePoint& spt ); // Constructor from a space vector. SpacePath( const SpacePointVector& svec ); // Destructor. virtual ~SpacePath( ); // Cartesian dx. double dx( ) const { return v_x(); }; // Cartesian dy. double dy( ) const { return v_y(); }; // Cartesian or cylindrical dz. double dz( ) const { return v_z(); }; // Cylindrical drxy. // Can be well defined at rxy=0. double drxy( ) const { return v_rxy(); }; // Cylindrical or spherical rxy*dphi. // Can be well defined at rxy=0. double rxy_dphi( ) const { return v_phi(); }; // Cylindrical or spherical dphi. // Not well defined at rxy=0. double dphi( ) const { return v_phi()/v_rxy(); }; // Spherical rxyz. // Can be well defined at rxyz=0. double drxyz( ) const { return v_rxyz(); }; // Spherical rxyz*dtheta. // Can be well defined at rxyz=0. double rxyz_dtheta( ) const { return v_theta(); }; // Spherical dtheta. // Not well defined at rxyz=0; double dtheta( ) const { return v_theta()/v_rxyz(); }; }; std::ostream& operator<<(std::ostream & stream, const SpacePath& svec); //********************************************************************** class CartesianPath : public SpacePath { public: // Constructor from coordinates and direction. CartesianPath(double x, double y, double z, double dx, double dy, double dz); // Constructor from space point and direction. CartesianPath(const SpacePoint& spt, double dx, double dy, double dz); }; //********************************************************************** class CylindricalPath : public SpacePath { public: // Constructor from coordinates and direction. CylindricalPath(double r, double phi, double z, double dr, double r_dphi, double dz); // Constructor from space point and direction. CylindricalPath(const SpacePoint& spt, double dr, double r_dphi, double dz); }; //********************************************************************** class SphericalPath : public SpacePath { public: // Constructor from coordinates and direction. // Arguments are (dr, r*dtheta, r*sin(theta)*dphi). SphericalPath(double r, double theta, double phi, double dr, double r_dtheta, double rt_dphi); // Constructor from space point and direction. SphericalPath(const SpacePoint& spt, double dr, double r_dtheta, double rt_dphi); }; //********************************************************************** #endif