diff --git a/math/genvector/inc/Math/GenVector/Boost.h b/math/genvector/inc/Math/GenVector/Boost.h index d4b7a8f4701dc786fa25c6988bef64e2ed7d2ea3..794cda26a9fa9bf359e274e3fe564c06baba4e38 100644 --- a/math/genvector/inc/Math/GenVector/Boost.h +++ b/math/genvector/inc/Math/GenVector/Boost.h @@ -90,6 +90,13 @@ public: template<class IT> Boost(IT begin, IT end) { SetComponents(begin,end); } + /** + copy constructor + */ + Boost(Boost const & b) { + *this = b; + } + /** Construct from an axial boost */ @@ -100,6 +107,17 @@ public: // The compiler-generated copy ctor, copy assignment, and dtor are OK. + /** + Assignment operator + */ + Boost & + operator=(Boost const & rhs ) { + for (unsigned int i=0; i < 10; ++i) { + fM[i] = rhs.fM[i]; + } + return *this; + } + /** Assign from an axial pure boost */ diff --git a/math/genvector/inc/Math/GenVector/Plane3D.h b/math/genvector/inc/Math/GenVector/Plane3D.h index 1fdda68653493d93086b8d3ed0885f5faeedf85f..7e4f60c9496da474c4047b869ab45b5cbd0e3f09 100644 --- a/math/genvector/inc/Math/GenVector/Plane3D.h +++ b/math/genvector/inc/Math/GenVector/Plane3D.h @@ -77,7 +77,10 @@ namespace Math { \param n normal expressed as a ROOT::Math::DisplacementVector3D<Cartesian3D<double> > \param p point expressed as a ROOT::Math::PositionVector3D<Cartesian3D<double> > */ - Plane3D(const Vector & n, const Point & p ); + Plane3D(const Vector & n, const Point & p ) + { + BuildFromVecAndPoint( n, p ); + } /** @@ -87,9 +90,10 @@ namespace Math { \param p point expressed as a generic ROOT::Math::PositionVector3D */ template<class T1, class T2, class U> - Plane3D( const DisplacementVector3D<T1,U> & n, const PositionVector3D<T2,U> & p) : - Plane3D( Vector(n.X(), n.Y(), n.Z()), Point(p.X(), p.Y(), p.Z()) ) - {} + Plane3D( const DisplacementVector3D<T1,U> & n, const PositionVector3D<T2,U> & p) + { + BuildFromVecAndPoint( Vector(n), Point(p) ); + } /** constructor from three Cartesian point belonging to the plane @@ -98,7 +102,9 @@ namespace Math { \param p3 point3 expressed as a generic ROOT::Math::PositionVector3D */ - Plane3D(const Point & p1, const Point & p2, const Point & p3 ); + Plane3D(const Point & p1, const Point & p2, const Point & p3 ) { + BuildFrom3Points(p1,p2,p3); + } /** constructor from three generic point belonging to the plane @@ -107,11 +113,12 @@ namespace Math { \param p3 point3 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<double> > */ template <class T1, class T2, class T3, class U> - Plane3D(const PositionVector3D<T1,U> & p1, const PositionVector3D<T2,U> & p2, const PositionVector3D<T3,U> & p3 ) : - Plane3D ( Point(p1.X(), p1.Y(), p1.Z()), - Point(p2.X(), p2.Y(), p2.Z()), - Point(p3.X(), p3.Y(), p3.Z()) ) - {} + Plane3D(const PositionVector3D<T1,U> & p1, const PositionVector3D<T2,U> & p2, const PositionVector3D<T3,U> & p3 ) + { + BuildFrom3Points( Point(p1.X(), p1.Y(), p1.Z()), + Point(p2.X(), p2.Y(), p2.Z()), + Point(p3.X(), p3.Y(), p3.Z()) ); + } @@ -229,6 +236,11 @@ namespace Math { private: + // internal method to construct class from a vector and a point + void BuildFromVecAndPoint(const Vector & n, const Point & p); + // internal method to construct class from 3 points + void BuildFrom3Points(const Point & p1, const Point & p2, const Point & p3); + // plane data members the four scalar which satisfies fA*x + fB*y + fC*z + fD = 0 // for every point (x,y,z) belonging to the plane. // fA**2 + fB**2 + fC** =1 plane is stored in normalized form diff --git a/math/genvector/inc/Math/GenVector/Rotation3D.h b/math/genvector/inc/Math/GenVector/Rotation3D.h index ccfb9042716a317ea0fb5e0cd1634bd6a4bc91e8..5eee64af4977af12a3f426bd3a5444200d36cec3 100644 --- a/math/genvector/inc/Math/GenVector/Rotation3D.h +++ b/math/genvector/inc/Math/GenVector/Rotation3D.h @@ -88,6 +88,13 @@ public: template<class IT> Rotation3D(IT begin, IT end) { SetComponents(begin,end); } + /** + copy constructor + */ + Rotation3D ( Rotation3D const & r ) { + *this = r; + } + /** Construct from an AxisAngle */ @@ -135,7 +142,7 @@ public: const ForeignVector& v2, const ForeignVector& v3 ) { SetComponents(v1, v2, v3); } - // The compiler-generated copy ctor, copy assignment, and dtor are OK. + // compiler generated destruuctor is ok /** Raw constructor from nine Scalar components (without any checking) @@ -147,6 +154,25 @@ public: SetComponents (xx, xy, xz, yx, yy, yz, zx, zy, zz); } + // need to implement assignment operator to avoid using the templated one + + /** + Assignment operator + */ + Rotation3D & + operator=( Rotation3D const & rhs ) { + fM[0] = rhs.fM[0]; + fM[1] = rhs.fM[1]; + fM[2] = rhs.fM[2]; + fM[3] = rhs.fM[3]; + fM[4] = rhs.fM[4]; + fM[5] = rhs.fM[5]; + fM[6] = rhs.fM[6]; + fM[7] = rhs.fM[7]; + fM[8] = rhs.fM[8]; + return *this; + } + /** Assign from an AxisAngle */ @@ -187,7 +213,12 @@ public: */ template<class ForeignMatrix> Rotation3D & - operator=(const ForeignMatrix & m) { SetComponents(m); return *this; } + operator=(const ForeignMatrix & m) { + SetComponents( m(0,0), m(0,1), m(0,2), + m(1,0), m(1,1), m(1,2), + m(2,0), m(2,1), m(2,2) ); + return *this; + } /** Re-adjust components to eliminate small deviations from perfect diff --git a/math/genvector/src/Plane3D.cxx b/math/genvector/src/Plane3D.cxx index 1821b4f1a9cdd909a1025abfeb35fa054de64c88..cb51cee9b8c85ce1867dba2ac54a075ab9568008 100644 --- a/math/genvector/src/Plane3D.cxx +++ b/math/genvector/src/Plane3D.cxx @@ -35,24 +35,25 @@ typedef Plane3D::Vector XYZVector; // constructor from 4 scalars numbers (a,b,c,d) Plane3D::Plane3D(const Scalar & a, const Scalar & b, const Scalar & c, const Scalar & d) : - fA(a), fB(b), fC(c), fD(d) { - //renormalize a,b,c to unit - Normalize(); - } - -// construct from a normal vector and a point -Plane3D::Plane3D(const XYZVector & n, const XYZPoint & p ) : - fA( n.X() ), - fB( n.Y() ), - fC( n.Z() ) + fA(a), fB(b), fC(c), fD(d) { - fD = - n.Dot(p); - Normalize(); - + //renormalize a,b,c to unit + Normalize(); +} + +// internal method to construct from a normal vector and a point +void Plane3D::BuildFromVecAndPoint(const XYZVector & n, const XYZPoint & p ) +{ + // build from a normal vector and a point + fA = n.X(); + fB = n.Y(); + fC = n.Z(); + fD = - n.Dot(p); + Normalize(); } -// constructor from three points -Plane3D::Plane3D( const XYZPoint & p1, const XYZPoint & p2, const XYZPoint & p3 ) { +// internl method to construct from three points +void Plane3D::BuildFrom3Points( const XYZPoint & p1, const XYZPoint & p2, const XYZPoint & p3 ) { // plane from thre points // normal is (x3-x1) cross (x2 -x1) diff --git a/math/genvector/test/testGenVector.cxx b/math/genvector/test/testGenVector.cxx index 8f767768c063d53bbd4f9f0313280f3b72cb1493..9d1f2af46d785fd0acadead7d558e770d0036e72 100644 --- a/math/genvector/test/testGenVector.cxx +++ b/math/genvector/test/testGenVector.cxx @@ -571,7 +571,10 @@ int testTransform3D() { iret |= compare( trf11 == trf10, 1,"r3d * transf",1 ); RotationZYX rrr2 = trf10.Rotation<RotationZYX>(); - iret |= compare( rzyx == rrr2, 1,"gen Rotaton()",1 ); + //iret |= compare( rzyx == rrr2, 1,"gen Rotation()",1 ); + iret |= compare( rzyx.Phi() , rrr2.Phi(),"gen Rotation() Phi",1 ); + iret |= compare( rzyx.Theta(), rrr2.Theta(),"gen Rotation() Theta",10 ); + iret |= compare( rzyx.Psi(), rrr2.Psi(),"gen Rotation() Psi",1 ); if (iret) std::cout << rzyx << "\n---\n" << rrr2 << std::endl; @@ -631,7 +634,7 @@ int testTransform3D() { #endif - if (iret == 0) std::cout << "\tOK\n"; + if (iret == 0) std::cout << "OK\n"; else std::cout << "\t\t\tFAILED\n"; return iret;