Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:28

0001 // -*- C++ -*-
0002 // $Id: Vector3D.h,v 1.3 2003/10/23 21:29:50 garren Exp $
0003 // ---------------------------------------------------------------------------
0004 //
0005 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
0006 //
0007 // History:
0008 // 09.09.96 E.Chernyaev - initial version
0009 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
0010 //                        the functionality from CLHEP::Hep3Vector
0011 // 01.04.03 E.Chernyaev - CLHEP-1.9: template version
0012 //
0013 
0014 #ifndef HEP_VECTOR3D_H
0015 #define HEP_VECTOR3D_H
0016 
0017 #include <iosfwd>
0018 #include "CLHEP/Geometry/defs.h"
0019 #include "CLHEP/Vector/ThreeVector.h"
0020 #include "CLHEP/Geometry/BasicVector3D.h"
0021 
0022 namespace HepGeom {
0023 
0024   class Transform3D;
0025 
0026   /**
0027    * Geometrical 3D Vector.
0028    * This is just a declaration of the class needed to define
0029    * specializations Vector3D<float> and Vector3D<double>.
0030    *
0031    * @ingroup geometry
0032    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
0033    */
0034   template<class T>
0035   class Vector3D : public BasicVector3D<T> {};
0036 
0037   /**
0038    * Geometrical 3D Vector with components of float type.
0039    *
0040    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
0041    * @ingroup geometry
0042    */
0043   template<>
0044   class Vector3D<float> : public BasicVector3D<float> {
0045   public:
0046     /**
0047      * Default constructor. */
0048     Vector3D() = default;
0049 
0050     /**
0051      * Constructor from three numbers. */
0052     Vector3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
0053 
0054     /**
0055      * Constructor from array of floats. */
0056     explicit Vector3D(const float * a)
0057       : BasicVector3D<float>(a[0],a[1],a[2]) {}
0058 
0059     /**
0060      * Copy constructor. */
0061     Vector3D(const Vector3D<float> &) = default;
0062 
0063     /**
0064      * Move constructor. */
0065     Vector3D(Vector3D<float> &&) = default;
0066 
0067     /**
0068      * Constructor from BasicVector3D<float>. */
0069     Vector3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
0070 
0071     /**
0072      * Destructor. */
0073     ~Vector3D() = default;
0074 
0075     /**
0076      * Assignment. */
0077     Vector3D<float> & operator=(const Vector3D<float> &) = default;
0078 
0079     /**
0080      * Assignment from BasicVector3D<float>. */
0081     Vector3D<float> & operator=(const BasicVector3D<float> & v) {
0082       this->BasicVector3D<float>::operator=(v);
0083       return *this;
0084     }
0085 
0086     /**
0087      * Move assignment. */
0088     Vector3D<float> & operator=(Vector3D<float> &&) = default;
0089 
0090     /**
0091      * Transformation by Transform3D. */
0092     Vector3D<float> & transform(const Transform3D & m);
0093   };
0094 
0095   /**
0096    * Transformation of Vector<float> by Transform3D.
0097    * @relates Vector3D
0098    */
0099   Vector3D<float>
0100   operator*(const Transform3D & m, const Vector3D<float> & v);
0101 
0102   /**
0103    * Geometrical 3D Vector with components of double type.
0104    *
0105    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
0106    * @ingroup geometry
0107    */
0108   template<>
0109   class Vector3D<double> : public BasicVector3D<double> {
0110   public:
0111     /**
0112      * Default constructor. */
0113     Vector3D() = default;
0114 
0115     /**
0116      * Constructor from three numbers. */
0117     Vector3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
0118 
0119     /**
0120      * Constructor from array of floats. */
0121     explicit Vector3D(const float * a)
0122       : BasicVector3D<double>(a[0],a[1],a[2]) {}
0123 
0124     /**
0125      * Constructor from array of doubles. */
0126     explicit Vector3D(const double * a)
0127       : BasicVector3D<double>(a[0],a[1],a[2]) {}
0128 
0129     /**
0130      * Copy constructor. */
0131     Vector3D(const Vector3D<double> &) = default;
0132 
0133     /**
0134      * Move constructor. */
0135     Vector3D(Vector3D<double> &&) = default;
0136 
0137     /**
0138      * Constructor from BasicVector3D<float>. */
0139     Vector3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
0140 
0141     /**
0142      * Constructor from BasicVector3D<double>. */
0143     Vector3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
0144 
0145     /**
0146      * Destructor. */
0147     ~Vector3D() = default;
0148 
0149     /**
0150      * Constructor from CLHEP::Hep3Vector.
0151      * This constructor is needed only for backward compatibility and
0152      * in principle should be absent.
0153      */
0154     Vector3D(const CLHEP::Hep3Vector & v)
0155       : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
0156 
0157     /**
0158      * Conversion (cast) to CLHEP::Hep3Vector.
0159      * This operator is needed only for backward compatibility and
0160      * in principle should not exit.
0161      */
0162     operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
0163 
0164     /**
0165      * Assignment. */
0166     Vector3D<double> & operator=(const Vector3D<double> &) = default;
0167 
0168     /**
0169      * Assignment from BasicVector3D<float>. */
0170     Vector3D<double> & operator=(const BasicVector3D<float> & v) {
0171       this->BasicVector3D<double>::operator=(v);
0172       return *this;
0173     }
0174 
0175     /**
0176      * Assignment from BasicVector3D<double>. */
0177     Vector3D<double> & operator=(const BasicVector3D<double> & v) {
0178       this->BasicVector3D<double>::operator=(v);
0179       return *this;
0180     }
0181 
0182     /**
0183      * Move assignment. */
0184     Vector3D<double> & operator=(Vector3D<double> &&) = default;
0185 
0186     /**
0187      * Transformation by Transform3D. */
0188     Vector3D<double> & transform(const Transform3D & m);
0189   };
0190 
0191   /**
0192    * Transformation of Vector<double> by Transform3D.
0193    * @relates Vector3D
0194    */
0195   Vector3D<double>
0196   operator*(const Transform3D & m, const Vector3D<double> & v);
0197 
0198 } /* namespace HepGeom */
0199 
0200 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0201 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0202 typedef HepGeom::Vector3D<double> HepVector3D;
0203 #endif
0204 
0205 #endif /* HEP_VECTOR3D_H */