Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:20:04

0001 
0002 /***********************************************************************
0003 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
0004 *                                                                      *
0005 * This file is part of EvtGen.                                         *
0006 *                                                                      *
0007 * EvtGen is free software: you can redistribute it and/or modify       *
0008 * it under the terms of the GNU General Public License as published by *
0009 * the Free Software Foundation, either version 3 of the License, or    *
0010 * (at your option) any later version.                                  *
0011 *                                                                      *
0012 * EvtGen is distributed in the hope that it will be useful,            *
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
0015 * GNU General Public License for more details.                         *
0016 *                                                                      *
0017 * You should have received a copy of the GNU General Public License    *
0018 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
0019 ***********************************************************************/
0020 
0021 #ifndef EVTVECTOR3R_HH
0022 #define EVTVECTOR3R_HH
0023 
0024 #include <iosfwd>
0025 
0026 class EvtVector3R final {
0027     friend EvtVector3R rotateEuler( const EvtVector3R& v, double phi,
0028                                     double theta, double ksi );
0029 
0030     inline friend EvtVector3R operator*( double c, const EvtVector3R& v2 );
0031     inline friend double operator*( const EvtVector3R& v1, const EvtVector3R& v2 );
0032     inline friend EvtVector3R operator+( const EvtVector3R& v1,
0033                                          const EvtVector3R& v2 );
0034     inline friend EvtVector3R operator-( const EvtVector3R& v1,
0035                                          const EvtVector3R& v2 );
0036     inline friend EvtVector3R operator*( const EvtVector3R& v1, double c );
0037     inline friend EvtVector3R operator/( const EvtVector3R& v1, double c );
0038     friend EvtVector3R cross( const EvtVector3R& v1, const EvtVector3R& v2 );
0039 
0040   public:
0041     EvtVector3R();
0042     EvtVector3R( double x, double y, double z );
0043     inline EvtVector3R& operator*=( const double c );
0044     inline EvtVector3R& operator/=( const double c );
0045     inline EvtVector3R& operator+=( const EvtVector3R& v2 );
0046     inline EvtVector3R& operator-=( const EvtVector3R& v2 );
0047     inline void set( int i, double d );
0048     inline void set( double x, double y, double z );
0049     void applyRotateEuler( double phi, double theta, double ksi );
0050     inline double get( int i ) const;
0051     friend std::ostream& operator<<( std::ostream& s, const EvtVector3R& v );
0052     double dot( const EvtVector3R& v2 );
0053     double d3mag() const;
0054 
0055   private:
0056     double v[3];
0057 };
0058 
0059 inline EvtVector3R& EvtVector3R::operator*=( const double c )
0060 {
0061     v[0] *= c;
0062     v[1] *= c;
0063     v[2] *= c;
0064     return *this;
0065 }
0066 
0067 inline EvtVector3R& EvtVector3R::operator/=( const double c )
0068 {
0069     v[0] /= c;
0070     v[1] /= c;
0071     v[2] /= c;
0072     return *this;
0073 }
0074 
0075 inline EvtVector3R& EvtVector3R::operator+=( const EvtVector3R& v2 )
0076 {
0077     v[0] += v2.v[0];
0078     v[1] += v2.v[1];
0079     v[2] += v2.v[2];
0080     return *this;
0081 }
0082 
0083 inline EvtVector3R& EvtVector3R::operator-=( const EvtVector3R& v2 )
0084 {
0085     v[0] -= v2.v[0];
0086     v[1] -= v2.v[1];
0087     v[2] -= v2.v[2];
0088     return *this;
0089 }
0090 
0091 inline EvtVector3R operator*( double c, const EvtVector3R& v2 )
0092 {
0093     return EvtVector3R( v2 ) *= c;
0094 }
0095 
0096 inline EvtVector3R operator*( const EvtVector3R& v1, double c )
0097 {
0098     return EvtVector3R( v1 ) *= c;
0099 }
0100 
0101 inline EvtVector3R operator/( const EvtVector3R& v1, double c )
0102 {
0103     return EvtVector3R( v1 ) /= c;
0104 }
0105 
0106 inline double operator*( const EvtVector3R& v1, const EvtVector3R& v2 )
0107 {
0108     return v1.v[0] * v2.v[0] + v1.v[1] * v2.v[1] + v1.v[2] * v2.v[2];
0109 }
0110 
0111 inline EvtVector3R operator+( const EvtVector3R& v1, const EvtVector3R& v2 )
0112 {
0113     return EvtVector3R( v1 ) += v2;
0114 }
0115 
0116 inline EvtVector3R operator-( const EvtVector3R& v1, const EvtVector3R& v2 )
0117 {
0118     return EvtVector3R( v1 ) -= v2;
0119 }
0120 
0121 inline double EvtVector3R::get( int i ) const
0122 {
0123     return v[i];
0124 }
0125 
0126 inline void EvtVector3R::set( int i, double d )
0127 {
0128     v[i] = d;
0129 }
0130 
0131 inline void EvtVector3R::set( double x, double y, double z )
0132 {
0133     v[0] = x;
0134     v[1] = y;
0135     v[2] = z;
0136 }
0137 
0138 #endif