From b66f56fa267821ce1a47345a5e49181b9ccb00ea Mon Sep 17 00:00:00 2001 From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch> Date: Thu, 15 Jun 2006 16:23:44 +0000 Subject: [PATCH] changes for coding conventions git-svn-id: http://root.cern.ch/svn/root/trunk@15445 27541ba8-7e3a-0410-8455-c3a389f83636 --- mathcore/inc/Math/GenVector/AxisAngle.h | 14 +- mathcore/inc/Math/GenVector/BitReproducible.h | 12 +- mathcore/inc/Math/GenVector/Boost.h | 28 +-- mathcore/inc/Math/GenVector/BoostX.h | 28 +-- mathcore/inc/Math/GenVector/BoostY.h | 28 +-- mathcore/inc/Math/GenVector/BoostZ.h | 28 +-- mathcore/inc/Math/GenVector/EulerAngles.h | 10 +- mathcore/inc/Math/GenVector/LorentzRotation.h | 68 +++---- mathcore/inc/Math/GenVector/Quaternion.h | 16 +- mathcore/inc/Math/GenVector/Rotation3D.h | 60 +++--- mathcore/inc/Math/GenVector/RotationX.h | 12 +- mathcore/inc/Math/GenVector/RotationY.h | 12 +- mathcore/inc/Math/GenVector/RotationZ.h | 12 +- mathcore/src/3DConversions.cxx | 164 +++++++++------ mathcore/src/3DDistances.cxx | 10 +- mathcore/src/AxisAngle.cxx | 10 +- mathcore/src/AxisAngleXother.cxx | 54 +++-- mathcore/src/BitReproducible.cxx | 62 +++--- mathcore/src/Boost.cxx | 108 +++++----- mathcore/src/BoostX.cxx | 49 +++-- mathcore/src/BoostY.cxx | 47 ++--- mathcore/src/BoostZ.cxx | 47 ++--- mathcore/src/EulerAngles.cxx | 49 ++--- mathcore/src/LorentzRotation.cxx | 190 +++++++++--------- mathcore/src/Plane3D.cxx | 4 +- mathcore/src/Quaternion.cxx | 33 ++- mathcore/src/QuaternionXaxial.cxx | 19 +- mathcore/src/Rotation3D.cxx | 153 +++++++------- mathcore/src/Rotation3DxAxial.cxx | 38 ++-- mathcore/src/Transform3D.cxx | 18 +- 30 files changed, 701 insertions(+), 682 deletions(-) diff --git a/mathcore/inc/Math/GenVector/AxisAngle.h b/mathcore/inc/Math/GenVector/AxisAngle.h index e1a363705b5..3bd55f32e54 100644 --- a/mathcore/inc/Math/GenVector/AxisAngle.h +++ b/mathcore/inc/Math/GenVector/AxisAngle.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: AxisAngle.h,v 1.5 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: AxisAngle.h,v 1.6 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -206,9 +206,9 @@ public: DisplacementVector3D<CoordSystem, Tag> operator() (const DisplacementVector3D<CoordSystem, Tag> & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v.X(), v.Y(), v.Z()); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); DisplacementVector3D< CoordSystem, Tag > vNew; - vNew.SetXYZ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + vNew.SetXYZ( rxyz.X(), rxyz.Y(), rxyz.Z() ); return vNew; } @@ -219,8 +219,8 @@ public: PositionVector3D<CoordSystem, Tag> operator() (const PositionVector3D<CoordSystem,Tag> & p) const { DisplacementVector3D< Cartesian3D<double>,Tag > xyz(p); - DisplacementVector3D< Cartesian3D<double>,Tag > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,Tag> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,Tag > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,Tag> ( rxyz ); } /** @@ -245,8 +245,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/BitReproducible.h b/mathcore/inc/Math/GenVector/BitReproducible.h index d204fd72ee9..928d7a48e74 100644 --- a/mathcore/inc/Math/GenVector/BitReproducible.h +++ b/mathcore/inc/Math/GenVector/BitReproducible.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BitReproducible.h,v 1.3 2005/09/19 15:50:04 brun Exp $ +// @(#)root/mathcore:$Name: $:$Id: BitReproducible.h,v 1.4 2005/12/12 13:46:42 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: fischler at Mon Jun 25 2005 // -// Last update: $Id: BitReproducible.h,v 1.3 2005/09/19 15:50:04 brun Exp $ +// Last update: $Id: BitReproducible.h,v 1.4 2005/12/12 13:46:42 moneta Exp $ // #ifndef ROOT_Math_GenVector_BitReproducible #define ROOT_Math_GenVector_BitReproducible 1 @@ -95,12 +95,12 @@ public: private: union DB8 { - unsigned char b[8]; - double d; + unsigned char fB[8]; + double fD; }; static void Fill_byte_order (); - static bool byte_order_known; - static int byte_order[8]; + static bool fgByte_order_known; + static int fgByte_order[8]; // Meaning of byte_order: The first (high-order in IEEE 754) byte to // output (or the high-order byte of the first unsigned long) // is of db.b[byte_order[0]]. Thus the index INTO byte_order diff --git a/mathcore/inc/Math/GenVector/Boost.h b/mathcore/inc/Math/GenVector/Boost.h index 90f354611ce..070cd11e915 100644 --- a/mathcore/inc/Math/GenVector/Boost.h +++ b/mathcore/inc/Math/GenVector/Boost.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Boost.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Boost.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon Nov 1 2005 // -// Last update: $Id: Boost.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// Last update: $Id: Boost.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // #ifndef ROOT_Math_GenVector_Boost #define ROOT_Math_GenVector_Boost 1 @@ -49,17 +49,17 @@ public: typedef double Scalar; enum LorentzRotationMatrixIndex { - LXX = 0, LXY = 1, LXZ = 2, LXT = 3 - , LYX = 4, LYY = 5, LYZ = 6, LYT = 7 - , LZX = 8, LZY = 9, LZZ = 10, LZT = 11 - , LTX = 12, LTY = 13, LTZ = 14, LTT = 15 + kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3 + , kLYX = 4, kLYY = 5, kLYZ = 6, kLYT = 7 + , kLZX = 8, kLZY = 9, kLZZ = 10, kLZT = 11 + , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15 }; enum BoostMatrixIndex { - XX = 0, XY = 1, XZ = 2, XT = 3 - , YY = 4, YZ = 5, YT = 6 - , ZZ = 7, ZT = 8 - , TT = 9 + kXX = 0, kXY = 1, kXZ = 2, kXT = 3 + , kYY = 4, kYZ = 5, kYT = 6 + , kZZ = 7, kZT = 8 + , kTT = 9 }; // ========== Constructors and Assignment ===================== @@ -189,8 +189,8 @@ public: LorentzVector<CoordSystem> operator() (const LorentzVector<CoordSystem> & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return LorentzVector<CoordSystem> ( Rxyzt ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return LorentzVector<CoordSystem> ( r_xyzt ); } /** @@ -202,8 +202,8 @@ public: Foreign4Vector operator() (const Foreign4Vector & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return Foreign4Vector ( Rxyzt.X(), Rxyzt.Y(), Rxyzt.Z(), Rxyzt.T() ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() ); } /** diff --git a/mathcore/inc/Math/GenVector/BoostX.h b/mathcore/inc/Math/GenVector/BoostX.h index f6e5f5a37f4..9d36819ef2c 100644 --- a/mathcore/inc/Math/GenVector/BoostX.h +++ b/mathcore/inc/Math/GenVector/BoostX.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BoostX.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: BoostX.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon Nov 1 2005 // -// Last update: $Id: BoostX.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// Last update: $Id: BoostX.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // #ifndef ROOT_Math_GenVector_BoostX #define ROOT_Math_GenVector_BoostX 1 @@ -43,17 +43,17 @@ public: typedef double Scalar; enum LorentzRotationMatrixIndex { - LXX = 0, LXY = 1, LXZ = 2, LXT = 3 - , LYX = 4, LYY = 5, LYZ = 6, LYT = 7 - , LZX = 8, LZY = 9, LZZ = 10, LZT = 11 - , LTX = 12, LTY = 13, LTZ = 14, LTT = 15 + kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3 + , kLYX = 4, kLYY = 5, kLYZ = 6, kLYT = 7 + , kLZX = 8, kLZY = 9, kLZZ = 10, kLZT = 11 + , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15 }; enum BoostMatrixIndex { - XX = 0, XY = 1, XZ = 2, XT = 3 - , YY = 4, YZ = 5, YT = 6 - , ZZ = 7, ZT = 8 - , TT = 9 + kXX = 0, kXY = 1, kXZ = 2, kXT = 3 + , kYY = 4, kYZ = 5, kYT = 6 + , kZZ = 7, kZT = 8 + , kTT = 9 }; // ========== Constructors and Assignment ===================== @@ -139,8 +139,8 @@ public: LorentzVector<CoordSystem> operator() (const LorentzVector<CoordSystem> & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return LorentzVector<CoordSystem> ( Rxyzt ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return LorentzVector<CoordSystem> ( r_xyzt ); } /** @@ -152,8 +152,8 @@ public: Foreign4Vector operator() (const Foreign4Vector & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return Foreign4Vector ( Rxyzt.X(), Rxyzt.Y(), Rxyzt.Z(), Rxyzt.T() ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() ); } /** diff --git a/mathcore/inc/Math/GenVector/BoostY.h b/mathcore/inc/Math/GenVector/BoostY.h index fbbbc2c1b01..ffa16220c01 100644 --- a/mathcore/inc/Math/GenVector/BoostY.h +++ b/mathcore/inc/Math/GenVector/BoostY.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BoostY.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: BoostY.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon Nov 1 2005 // -// Last update: $Id: BoostY.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// Last update: $Id: BoostY.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // #ifndef ROOT_Math_GenVector_BoostY #define ROOT_Math_GenVector_BoostY 1 @@ -43,17 +43,17 @@ public: typedef double Scalar; enum LorentzRotationMatrixIndex { - LXX = 0, LXY = 1, LXZ = 2, LXT = 3 - , LYX = 4, LYY = 5, LYZ = 6, LYT = 7 - , LZX = 8, LZY = 9, LZZ = 10, LZT = 11 - , LTX = 12, LTY = 13, LTZ = 14, LTT = 15 + kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3 + , kLYX = 4, kLYY = 5, kLYZ = 6, kLYT = 7 + , kLZX = 8, kLZY = 9, kLZZ = 10, kLZT = 11 + , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15 }; enum BoostMatrixIndex { - XX = 0, XY = 1, XZ = 2, XT = 3 - , YY = 4, YZ = 5, YT = 6 - , ZZ = 7, ZT = 8 - , TT = 9 + kXX = 0, kXY = 1, kXZ = 2, kXT = 3 + , kYY = 4, kYZ = 5, kYT = 6 + , kZZ = 7, kZT = 8 + , kTT = 9 }; // ========== Constructors and Assignment ===================== @@ -139,8 +139,8 @@ public: LorentzVector<CoordSystem> operator() (const LorentzVector<CoordSystem> & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return LorentzVector<CoordSystem> ( Rxyzt ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return LorentzVector<CoordSystem> ( r_xyzt ); } /** @@ -152,8 +152,8 @@ public: Foreign4Vector operator() (const Foreign4Vector & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return Foreign4Vector ( Rxyzt.X(), Rxyzt.Y(), Rxyzt.Z(), Rxyzt.T() ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() ); } /** diff --git a/mathcore/inc/Math/GenVector/BoostZ.h b/mathcore/inc/Math/GenVector/BoostZ.h index d129e3746a3..5fd8bd72385 100644 --- a/mathcore/inc/Math/GenVector/BoostZ.h +++ b/mathcore/inc/Math/GenVector/BoostZ.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BoostZ.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: BoostZ.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon Nov 1 2005 // -// Last update: $Id: BoostZ.h,v 1.3 2006/04/11 13:06:15 moneta Exp $ +// Last update: $Id: BoostZ.h,v 1.4 2006/05/26 15:10:39 moneta Exp $ // #ifndef ROOT_Math_GenVector_BoostZ #define ROOT_Math_GenVector_BoostZ 1 @@ -43,17 +43,17 @@ public: typedef double Scalar; enum LorentzRotationMatrixIndex { - LXX = 0, LXY = 1, LXZ = 2, LXT = 3 - , LYX = 4, LYY = 5, LYZ = 6, LYT = 7 - , LZX = 8, LZY = 9, LZZ = 10, LZT = 11 - , LTX = 12, LTY = 13, LTZ = 14, LTT = 15 + kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3 + , kLYX = 4, kLYY = 5, kLYZ = 6, kLYT = 7 + , kLZX = 8, kLZY = 9, kLZZ = 10, kLZT = 11 + , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15 }; enum BoostMatrixIndex { - XX = 0, XY = 1, XZ = 2, XT = 3 - , YY = 4, YZ = 5, YT = 6 - , ZZ = 7, ZT = 8 - , TT = 9 + kXX = 0, kXY = 1, kXZ = 2, kXT = 3 + , kYY = 4, kYZ = 5, kYT = 6 + , kZZ = 7, kZT = 8 + , kTT = 9 }; // ========== Constructors and Assignment ===================== @@ -139,8 +139,8 @@ public: LorentzVector<CoordSystem> operator() (const LorentzVector<CoordSystem> & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return LorentzVector<CoordSystem> ( Rxyzt ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return LorentzVector<CoordSystem> ( r_xyzt ); } /** @@ -152,8 +152,8 @@ public: Foreign4Vector operator() (const Foreign4Vector & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return Foreign4Vector ( Rxyzt.X(), Rxyzt.Y(), Rxyzt.Z(), Rxyzt.T() ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() ); } /** diff --git a/mathcore/inc/Math/GenVector/EulerAngles.h b/mathcore/inc/Math/GenVector/EulerAngles.h index 99f6aed0055..ea70d4a9b9d 100644 --- a/mathcore/inc/Math/GenVector/EulerAngles.h +++ b/mathcore/inc/Math/GenVector/EulerAngles.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: EulerAngles.h,v 1.6 2006/02/06 17:22:03 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: EulerAngles.h,v 1.7 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -216,8 +216,8 @@ public: PositionVector3D<CoordSystem, U> operator() (const PositionVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz(v); - DisplacementVector3D< Cartesian3D<double>,U > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,U> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,U> ( rxyz ); } /** @@ -241,8 +241,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/LorentzRotation.h b/mathcore/inc/Math/GenVector/LorentzRotation.h index 82de500bb5f..219cdc7a006 100644 --- a/mathcore/inc/Math/GenVector/LorentzRotation.h +++ b/mathcore/inc/Math/GenVector/LorentzRotation.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: LorentzRotation.h,v 1.6 2005/11/24 14:45:50 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: LorentzRotation.h,v 1.7 2005/12/08 15:52:41 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon Aug 8 2005 // -// Last update: $Id: LorentzRotation.h,v 1.6 2005/11/24 14:45:50 moneta Exp $ +// Last update: $Id: LorentzRotation.h,v 1.7 2005/12/08 15:52:41 moneta Exp $ // #ifndef ROOT_Math_GenVector_LorentzRotation #define ROOT_Math_GenVector_LorentzRotation 1 @@ -57,10 +57,10 @@ public: typedef double Scalar; enum LorentzRotationMatrixIndex { - XX = 0, XY = 1, XZ = 2, XT = 3 - , YX = 4, YY = 5, YZ = 6, YT = 7 - , ZX = 8, ZY = 9, ZZ = 10, ZT = 11 - , TX = 12, TY = 13, TZ = 14, TT = 15 + kXX = 0, kXY = 1, kXZ = 2, kXT = 3 + , kYX = 4, kYY = 5, kYZ = 6, kYT = 7 + , kZX = 8, kZY = 9, kZZ = 10, kZT = 11 + , kTX = 12, kTY = 13, kTZ = 14, kTT = 15 }; // ========== Constructors and Assignment ===================== @@ -201,10 +201,10 @@ public: const Foreign4Vector& v2, const Foreign4Vector& v3, const Foreign4Vector& v4 ) { - fM[XX]=v1.x(); fM[XY]=v2.x(); fM[XZ]=v3.x(); fM[XT]=v4.x(); - fM[YX]=v1.y(); fM[YY]=v2.y(); fM[YZ]=v3.y(); fM[YT]=v4.y(); - fM[ZX]=v1.z(); fM[ZY]=v2.z(); fM[ZZ]=v3.z(); fM[ZT]=v4.z(); - fM[TX]=v1.t(); fM[TY]=v2.t(); fM[TZ]=v3.t(); fM[TT]=v4.t(); + fM[kXX]=v1.x(); fM[kXY]=v2.x(); fM[kXZ]=v3.x(); fM[kXT]=v4.x(); + fM[kYX]=v1.y(); fM[kYY]=v2.y(); fM[kYZ]=v3.y(); fM[kYT]=v4.y(); + fM[kZX]=v1.z(); fM[kZY]=v2.z(); fM[kZZ]=v3.z(); fM[kZT]=v4.z(); + fM[kTX]=v1.t(); fM[kTY]=v2.t(); fM[kTZ]=v3.t(); fM[kTT]=v4.t(); Rectify(); } @@ -219,10 +219,10 @@ public: Foreign4Vector& v2, Foreign4Vector& v3, Foreign4Vector& v4 ) const { - v1 = Foreign4Vector ( fM[XX], fM[YX], fM[ZX], fM[TX] ); - v2 = Foreign4Vector ( fM[XY], fM[YY], fM[ZY], fM[TY] ); - v3 = Foreign4Vector ( fM[XZ], fM[YZ], fM[ZZ], fM[TZ] ); - v4 = Foreign4Vector ( fM[XT], fM[YT], fM[ZT], fM[TT] ); + v1 = Foreign4Vector ( fM[kXX], fM[kYX], fM[kZX], fM[kTX] ); + v2 = Foreign4Vector ( fM[kXY], fM[kYY], fM[kZY], fM[kTY] ); + v3 = Foreign4Vector ( fM[kXZ], fM[kYZ], fM[kZZ], fM[kTZ] ); + v4 = Foreign4Vector ( fM[kXT], fM[kYT], fM[kZT], fM[kTT] ); } /** @@ -254,10 +254,10 @@ public: template<class ForeignMatrix> void SetComponents (const ForeignMatrix & m) { - fM[XX]=m(0,0); fM[XY]=m(0,1); fM[XZ]=m(0,2); fM[XT]=m(0,3); - fM[YX]=m(1,0); fM[YY]=m(1,1); fM[YZ]=m(1,2); fM[YT]=m(1,3); - fM[ZX]=m(2,0); fM[ZY]=m(2,1); fM[ZZ]=m(2,2); fM[ZT]=m(2,3); - fM[TX]=m(3,0); fM[TY]=m(3,1); fM[TZ]=m(3,2); fM[TT]=m(3,3); + fM[kXX]=m(0,0); fM[kXY]=m(0,1); fM[kXZ]=m(0,2); fM[kXT]=m(0,3); + fM[kYX]=m(1,0); fM[kYY]=m(1,1); fM[kYZ]=m(1,2); fM[kYT]=m(1,3); + fM[kZX]=m(2,0); fM[kZY]=m(2,1); fM[kZZ]=m(2,2); fM[kZT]=m(2,3); + fM[kTX]=m(3,0); fM[kTY]=m(3,1); fM[kTZ]=m(3,2); fM[kTT]=m(3,3); } /** @@ -268,10 +268,10 @@ public: template<class ForeignMatrix> void GetComponents (ForeignMatrix & m) const { - m(0,0)=fM[XX]; m(0,1)=fM[XY]; m(0,2)=fM[XZ]; m(0,3)=fM[XT]; - m(1,0)=fM[YX]; m(1,1)=fM[YY]; m(1,2)=fM[YZ]; m(1,3)=fM[YT]; - m(2,0)=fM[ZX]; m(2,1)=fM[ZY]; m(2,2)=fM[ZZ]; m(2,3)=fM[ZT]; - m(3,0)=fM[TX]; m(3,1)=fM[TY]; m(3,2)=fM[TZ]; m(3,3)=fM[TT]; + m(0,0)=fM[kXX]; m(0,1)=fM[kXY]; m(0,2)=fM[kXZ]; m(0,3)=fM[kXT]; + m(1,0)=fM[kYX]; m(1,1)=fM[kYY]; m(1,2)=fM[kYZ]; m(1,3)=fM[kYT]; + m(2,0)=fM[kZX]; m(2,1)=fM[kZY]; m(2,2)=fM[kZZ]; m(2,3)=fM[kZT]; + m(3,0)=fM[kTX]; m(3,1)=fM[kTY]; m(3,2)=fM[kTZ]; m(3,3)=fM[kTT]; } /** @@ -282,10 +282,10 @@ public: Scalar yx, Scalar yy, Scalar yz, Scalar yt, Scalar zx, Scalar zy, Scalar zz, Scalar zt, Scalar tx, Scalar ty, Scalar tz, Scalar tt) { - fM[XX]=xx; fM[XY]=xy; fM[XZ]=xz; fM[XT]=xt; - fM[YX]=yx; fM[YY]=yy; fM[YZ]=yz; fM[YT]=yt; - fM[ZX]=zx; fM[ZY]=zy; fM[ZZ]=zz; fM[ZT]=zt; - fM[TX]=tx; fM[TY]=ty; fM[TZ]=tz; fM[TT]=tt; + fM[kXX]=xx; fM[kXY]=xy; fM[kXZ]=xz; fM[kXT]=xt; + fM[kYX]=yx; fM[kYY]=yy; fM[kYZ]=yz; fM[kYT]=yt; + fM[kZX]=zx; fM[kZY]=zy; fM[kZZ]=zz; fM[kZT]=zt; + fM[kTX]=tx; fM[kTY]=ty; fM[kTZ]=tz; fM[kTT]=tt; } /** @@ -296,10 +296,10 @@ public: Scalar &yx, Scalar &yy, Scalar &yz, Scalar &yt, Scalar &zx, Scalar &zy, Scalar &zz, Scalar &zt, Scalar &tx, Scalar &ty, Scalar &tz, Scalar &tt) const { - xx=fM[XX]; xy=fM[XY]; xz=fM[XZ]; xt=fM[XT]; - yx=fM[YX]; yy=fM[YY]; yz=fM[YZ]; yt=fM[YT]; - zx=fM[ZX]; zy=fM[ZY]; zz=fM[ZZ]; zt=fM[ZT]; - tx=fM[TX]; ty=fM[TY]; tz=fM[TZ]; tt=fM[TT]; + xx=fM[kXX]; xy=fM[kXY]; xz=fM[kXZ]; xt=fM[kXT]; + yx=fM[kYX]; yy=fM[kYY]; yz=fM[kYZ]; yt=fM[kYT]; + zx=fM[kZX]; zy=fM[kZY]; zz=fM[kZZ]; zt=fM[kZT]; + tx=fM[kTX]; ty=fM[kTY]; tz=fM[kTZ]; tt=fM[kTT]; } // =========== operations ============== @@ -319,8 +319,8 @@ public: LorentzVector<CoordSystem> operator() (const LorentzVector<CoordSystem> & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return LorentzVector<CoordSystem> ( Rxyzt ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return LorentzVector<CoordSystem> ( r_xyzt ); } /** @@ -332,8 +332,8 @@ public: Foreign4Vector operator() (const Foreign4Vector & v) const { LorentzVector< PxPyPzE4D<double> > xyzt(v); - LorentzVector< PxPyPzE4D<double> > Rxyzt = operator()(xyzt); - return Foreign4Vector ( Rxyzt.X(), Rxyzt.Y(), Rxyzt.Z(), Rxyzt.T() ); + LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt); + return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() ); } /** diff --git a/mathcore/inc/Math/GenVector/Quaternion.h b/mathcore/inc/Math/GenVector/Quaternion.h index 02e69138461..45141f07ced 100644 --- a/mathcore/inc/Math/GenVector/Quaternion.h +++ b/mathcore/inc/Math/GenVector/Quaternion.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Quaternion.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Quaternion.h,v 1.5 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -11,7 +11,7 @@ // Header file for rotation in 3 dimensions, represented by a quaternion // Created by: Mark Fischler Thurs June 9 2005 // -// Last update: $Id: Quaternion.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ +// Last update: $Id: Quaternion.h,v 1.5 2006/05/26 15:10:39 moneta Exp $ // #ifndef ROOT_Math_GenVector_Quaternion #define ROOT_Math_GenVector_Quaternion 1 @@ -201,9 +201,9 @@ public: DisplacementVector3D<CoordSystem,Tag> operator() (const DisplacementVector3D<CoordSystem,Tag> & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v.X(), v.Y(), v.Z()); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); DisplacementVector3D< CoordSystem,Tag > vNew; - vNew.SetXYZ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + vNew.SetXYZ( rxyz.X(), rxyz.Y(), rxyz.Z() ); return vNew; } @@ -214,8 +214,8 @@ public: PositionVector3D<CoordSystem,Tag> operator() (const PositionVector3D<CoordSystem,Tag> & p) const { DisplacementVector3D< Cartesian3D<double>,Tag > xyz(p); - DisplacementVector3D< Cartesian3D<double>,Tag > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,Tag> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,Tag > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,Tag> ( rxyz ); } /** @@ -239,8 +239,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/Rotation3D.h b/mathcore/inc/Math/GenVector/Rotation3D.h index a4752b46d9f..b6bf59d740e 100644 --- a/mathcore/inc/Math/GenVector/Rotation3D.h +++ b/mathcore/inc/Math/GenVector/Rotation3D.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Rotation3D.h,v 1.5 2005/12/07 09:31:27 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Rotation3D.h,v 1.6 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Thurs June 9 2005 // -// Last update: $Id: Rotation3D.h,v 1.5 2005/12/07 09:31:27 moneta Exp $ +// Last update: $Id: Rotation3D.h,v 1.6 2006/04/11 13:06:15 moneta Exp $ // #ifndef ROOT_Math_GenVector_Rotation3D #define ROOT_Math_GenVector_Rotation3D 1 @@ -61,9 +61,9 @@ public: typedef double Scalar; enum Rotation3DMatrixIndex { - XX = 0, XY = 1, XZ = 2 - , YX = 3, YY = 4, YZ = 5 - , ZX = 6, ZY = 7, ZZ = 8 + kXX = 0, kXY = 1, kXZ = 2 + , kYX = 3, kYY = 4, kYZ = 5 + , kZX = 6, kZY = 7, kZZ = 8 }; // ========== Constructors and Assignment ===================== @@ -189,9 +189,9 @@ public: SetComponents (const ForeignVector& v1, const ForeignVector& v2, const ForeignVector& v3 ) { - fM[XX]=v1.x(); fM[XY]=v2.x(); fM[XZ]=v3.x(); - fM[YX]=v1.y(); fM[YY]=v2.y(); fM[YZ]=v3.y(); - fM[ZX]=v1.z(); fM[ZY]=v2.z(); fM[ZZ]=v3.z(); + fM[kXX]=v1.x(); fM[kXY]=v2.x(); fM[kXZ]=v3.x(); + fM[kYX]=v1.y(); fM[kYY]=v2.y(); fM[kYZ]=v3.y(); + fM[kZX]=v1.z(); fM[kZY]=v2.z(); fM[kZZ]=v3.z(); Rectify(); } @@ -205,9 +205,9 @@ public: GetComponents ( ForeignVector& v1, ForeignVector& v2, ForeignVector& v3 ) { - v1 = ForeignVector ( fM[XX], fM[XY], fM[XZ] ); - v2 = ForeignVector ( fM[YX], fM[YY], fM[YZ] ); - v3 = ForeignVector ( fM[ZX], fM[ZY], fM[ZZ] ); + v1 = ForeignVector ( fM[kXX], fM[kXY], fM[kXZ] ); + v2 = ForeignVector ( fM[kYX], fM[kYY], fM[kYZ] ); + v3 = ForeignVector ( fM[kZX], fM[kZY], fM[kZZ] ); } /** @@ -239,9 +239,9 @@ public: template<class ForeignMatrix> void SetComponents (const ForeignMatrix & m) { - fM[XX]=m(0,0); fM[XY]=m(0,1); fM[XZ]=m(0,2); - fM[YX]=m(1,0); fM[YY]=m(1,1); fM[YZ]=m(1,2); - fM[ZX]=m(2,0); fM[ZY]=m(2,1); fM[ZZ]=m(2,2); + fM[kXX]=m(0,0); fM[kXY]=m(0,1); fM[kXZ]=m(0,2); + fM[kYX]=m(1,0); fM[kYY]=m(1,1); fM[kYZ]=m(1,2); + fM[kZX]=m(2,0); fM[kZY]=m(2,1); fM[kZZ]=m(2,2); } /** @@ -252,9 +252,9 @@ public: template<class ForeignMatrix> void GetComponents (ForeignMatrix & m) const { - m(0,0)=fM[XX]; m(0,1)=fM[XY]; m(0,2)=fM[XZ]; - m(1,0)=fM[YX]; m(1,1)=fM[YY]; m(1,2)=fM[YZ]; - m(2,0)=fM[ZX]; m(2,1)=fM[ZY]; m(2,2)=fM[ZZ]; + m(0,0)=fM[kXX]; m(0,1)=fM[kXY]; m(0,2)=fM[kXZ]; + m(1,0)=fM[kYX]; m(1,1)=fM[kYY]; m(1,2)=fM[kYZ]; + m(2,0)=fM[kZX]; m(2,1)=fM[kZY]; m(2,2)=fM[kZZ]; } /** @@ -264,9 +264,9 @@ public: SetComponents (Scalar xx, Scalar xy, Scalar xz, Scalar yx, Scalar yy, Scalar yz, Scalar zx, Scalar zy, Scalar zz) { - fM[XX]=xx; fM[XY]=xy; fM[XZ]=xz; - fM[YX]=yx; fM[YY]=yy; fM[YZ]=yz; - fM[ZX]=zx; fM[ZY]=zy; fM[ZZ]=zz; + fM[kXX]=xx; fM[kXY]=xy; fM[kXZ]=xz; + fM[kYX]=yx; fM[kYY]=yy; fM[kYZ]=yz; + fM[kZX]=zx; fM[kZY]=zy; fM[kZZ]=zz; } /** @@ -276,9 +276,9 @@ public: GetComponents (Scalar &xx, Scalar &xy, Scalar &xz, Scalar &yx, Scalar &yy, Scalar &yz, Scalar &zx, Scalar &zy, Scalar &zz) const { - xx=fM[XX]; xy=fM[XY]; xz=fM[XZ]; - yx=fM[YX]; yy=fM[YY]; yz=fM[YZ]; - zx=fM[ZX]; zy=fM[ZY]; zz=fM[ZZ]; + xx=fM[kXX]; xy=fM[kXY]; xz=fM[kXZ]; + yx=fM[kYX]; yy=fM[kYY]; yz=fM[kYZ]; + zx=fM[kZX]; zy=fM[kZY]; zz=fM[kZZ]; } // =========== operations ============== @@ -291,9 +291,9 @@ public: DisplacementVector3D<CoordSystem,U> operator() (const DisplacementVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz; - xyz.SetXYZ( fM[XX] * v.X() + fM[XY] * v.Y() + fM[XZ] * v.Z() , - fM[YX] * v.X() + fM[YY] * v.Y() + fM[YZ] * v.Z() , - fM[ZX] * v.X() + fM[ZY] * v.Y() + fM[ZZ] * v.Z() ); + xyz.SetXYZ( fM[kXX] * v.X() + fM[kXY] * v.Y() + fM[kXZ] * v.Z() , + fM[kYX] * v.X() + fM[kYY] * v.Y() + fM[kYZ] * v.Z() , + fM[kZX] * v.X() + fM[kZY] * v.Y() + fM[kZZ] * v.Z() ); return DisplacementVector3D<CoordSystem,U>( xyz ); } @@ -304,8 +304,8 @@ public: PositionVector3D<CoordSystem,U> operator() (const PositionVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz(v); - DisplacementVector3D< Cartesian3D<double>,U > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,U> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,U> ( rxyz ); } /** @@ -329,8 +329,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/RotationX.h b/mathcore/inc/Math/GenVector/RotationX.h index 28bddfbe39e..4de29e9b446 100644 --- a/mathcore/inc/Math/GenVector/RotationX.h +++ b/mathcore/inc/Math/GenVector/RotationX.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: RotationX.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: RotationX.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon July 18 2005 // -// Last update: $Id: RotationX.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// Last update: $Id: RotationX.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // #ifndef ROOT_Math_GenVector_RotationX #define ROOT_Math_GenVector_RotationX 1 @@ -131,8 +131,8 @@ public: PositionVector3D<CoordSystem, U> operator() (const PositionVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz(v); - DisplacementVector3D< Cartesian3D<double>,U > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,U> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,U> ( rxyz ); } /** @@ -156,8 +156,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/RotationY.h b/mathcore/inc/Math/GenVector/RotationY.h index bdc12857dea..f1232adfdfc 100644 --- a/mathcore/inc/Math/GenVector/RotationY.h +++ b/mathcore/inc/Math/GenVector/RotationY.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: RotationY.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: RotationY.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon July 18 2005 // -// Last update: $Id: RotationY.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// Last update: $Id: RotationY.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // #ifndef ROOT_Math_GenVector_RotationY #define ROOT_Math_GenVector_RotationY 1 @@ -131,8 +131,8 @@ public: PositionVector3D<CoordSystem, U> operator() (const PositionVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz(v); - DisplacementVector3D< Cartesian3D<double>,U > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,U> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,U> ( rxyz ); } /** @@ -156,8 +156,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/inc/Math/GenVector/RotationZ.h b/mathcore/inc/Math/GenVector/RotationZ.h index 25f31cc7d0c..75c3d0fa710 100644 --- a/mathcore/inc/Math/GenVector/RotationZ.h +++ b/mathcore/inc/Math/GenVector/RotationZ.h @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: RotationZ.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: RotationZ.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Mon July 18 2005 // -// Last update: $Id: RotationZ.h,v 1.3 2005/10/27 18:00:01 moneta Exp $ +// Last update: $Id: RotationZ.h,v 1.4 2006/04/11 13:06:15 moneta Exp $ // #ifndef ROOT_Math_GenVector_RotationZ #define ROOT_Math_GenVector_RotationZ 1 @@ -131,8 +131,8 @@ public: PositionVector3D<CoordSystem, U> operator() (const PositionVector3D<CoordSystem,U> & v) const { DisplacementVector3D< Cartesian3D<double>,U > xyz(v); - DisplacementVector3D< Cartesian3D<double>,U > Rxyz = operator()(xyz); - return PositionVector3D<CoordSystem,U> ( Rxyz ); + DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz); + return PositionVector3D<CoordSystem,U> ( rxyz ); } /** @@ -156,8 +156,8 @@ public: ForeignVector operator() (const ForeignVector & v) const { DisplacementVector3D< Cartesian3D<double> > xyz(v); - DisplacementVector3D< Cartesian3D<double> > Rxyz = operator()(xyz); - return ForeignVector ( Rxyz.X(), Rxyz.Y(), Rxyz.Z() ); + DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz); + return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() ); } /** diff --git a/mathcore/src/3DConversions.cxx b/mathcore/src/3DConversions.cxx index d6c1576d341..25eb0268e9e 100644 --- a/mathcore/src/3DConversions.cxx +++ b/mathcore/src/3DConversions.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: 3DConversions.cxx,v 1.2 2005/09/19 09:57:07 brun Exp $ +// @(#)root/mathcore:$Name: $:$Id: 3DConversions.cxx,v 1.3 2006/03/01 16:21:59 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler and Walter Brown Thurs July 7, 2005 // -// Last update: $Id: 3DConversions.cxx,v 1.2 2005/09/19 09:57:07 brun Exp $ +// Last update: $Id: 3DConversions.cxx,v 1.3 2006/03/01 16:21:59 moneta Exp $ // // TODO - For now, all conversions are grouped in this one compilation unit. @@ -37,43 +37,42 @@ namespace ROOT { namespace Math { namespace gv_detail { -enum Rotation3DMatrixIndex -{ XX = Rotation3D::XX, XY = Rotation3D::XY, XZ = Rotation3D::XZ -, YX = Rotation3D::YX, YY = Rotation3D::YY, YZ = Rotation3D::YZ -, ZX = Rotation3D::ZX, ZY = Rotation3D::ZY, ZZ = Rotation3D::ZZ +enum ERotation3DMatrixIndex +{ kXX = Rotation3D::kXX, kXY = Rotation3D::kXY, kXZ = Rotation3D::kXZ +, kYX = Rotation3D::kYX, kYY = Rotation3D::kYY, kYZ = Rotation3D::kYZ +, kZX = Rotation3D::kZX, kZY = Rotation3D::kZY, kZZ = Rotation3D::kZZ }; // ---------------------------------------------------------------------- -// conversions from Rotation3D - void convert( Rotation3D const & from, AxisAngle & to) { + // conversions from Rotation3D double m[9]; from.GetComponents(m, m+9); - const double Uz = m[YX] - m[XY]; - const double Uy = m[XZ] - m[ZX]; - const double Ux = m[ZY] - m[YZ]; + const double uZ = m[kYX] - m[kXY]; + const double uY = m[kXZ] - m[kZX]; + const double uX = m[kZY] - m[kYZ]; AxisAngle::AxisVector u; - if ( (Uz==0) && (Uy==0) && (Ux==0) ) { - if ( m[ZZ]>0 ) { + if ( (uZ==0) && (uY==0) && (uX==0) ) { + if ( m[kZZ]>0 ) { u.SetCoordinates(0,0,1); - } else if ( m[YY]>0 ) { + } else if ( m[kYY]>0 ) { u.SetCoordinates(0,1,0); } else { u.SetCoordinates(1,0,0); } } else { - u.SetCoordinates( Ux, Uy, Uz ); + u.SetCoordinates( uX, uY, uZ ); } //to.SetAxis(u); // Note: SetAxis does normalize static const double pi=3.14159265358979323; double angle; - const double cosdelta = (m[XX] + m[YY] + m[ZZ] - 1.0) / 2.0; + const double cosdelta = (m[kXX] + m[kYY] + m[kZZ] - 1.0) / 2.0; if (cosdelta > 1.0) { angle = 0; } else if (cosdelta < -1.0) { @@ -103,7 +102,7 @@ static void correctByPi ( double& psi, double& phi ) { void convert( Rotation3D const & from, EulerAngles & to) { - + // conversion from Rotation3D to Euler Angles // Mathematical justification appears in eulerAngleComputations.ps double r[9]; @@ -113,10 +112,10 @@ void convert( Rotation3D const & from, EulerAngles & to) double psiPlusPhi, psiMinusPhi; static const double pi=3.14159265358979323; - theta = (std::fabs(r[ZZ]) <= 1.0) ? std::acos(r[ZZ]) : - (r[ZZ] > 0.0) ? 0 : pi; + theta = (std::fabs(r[kZZ]) <= 1.0) ? std::acos(r[kZZ]) : + (r[kZZ] > 0.0) ? 0 : pi; - double cosTheta = r[ZZ]; + double cosTheta = r[kZZ]; if (cosTheta > 1) cosTheta = 1; if (cosTheta < -1) cosTheta = -1; @@ -125,20 +124,20 @@ void convert( Rotation3D const & from, EulerAngles & to) // is less than 1 in absolute value, different mathematically equivalent // expressions are numerically stable. if (cosTheta == 1) { - psiPlusPhi = atan2 ( r[XY] - r[YX], r[XX] + r[YY] ); + psiPlusPhi = atan2 ( r[kXY] - r[kYX], r[kXX] + r[kYY] ); psiMinusPhi = 0; } else if (cosTheta >= 0) { - psiPlusPhi = atan2 ( r[XY] - r[YX], r[XX] + r[YY] ); - double s = -r[XY] - r[YX]; // sin (psi-phi) * (1 - cos theta) - double c = r[XX] - r[YY]; // cos (psi-phi) * (1 - cos theta) + psiPlusPhi = atan2 ( r[kXY] - r[kYX], r[kXX] + r[kYY] ); + double s = -r[kXY] - r[kYX]; // sin (psi-phi) * (1 - cos theta) + double c = r[kXX] - r[kYY]; // cos (psi-phi) * (1 - cos theta) psiMinusPhi = atan2 ( s, c ); } else if (cosTheta > -1) { - psiMinusPhi = atan2 ( -r[XY] - r[YX], r[XX] - r[YY] ); - double s = r[XY] - r[YX]; // sin (psi+phi) * (1 + cos theta) - double c = r[XX] + r[YY]; // cos (psi+phi) * (1 + cos theta) + psiMinusPhi = atan2 ( -r[kXY] - r[kYX], r[kXX] - r[kYY] ); + double s = r[kXY] - r[kYX]; // sin (psi+phi) * (1 + cos theta) + double c = r[kXX] + r[kYY]; // cos (psi+phi) * (1 + cos theta) psiPlusPhi = atan2 ( s, c ); } else { // cosTheta == -1 - psiMinusPhi = atan2 ( -r[XY] - r[YX], r[XX] - r[YY] ); + psiMinusPhi = atan2 ( -r[kXY] - r[kYX], r[kXX] - r[kYY] ); psiPlusPhi = 0; } @@ -151,7 +150,7 @@ void convert( Rotation3D const & from, EulerAngles & to) // set up w[i], all of which would be positive if sin and cosine of // psi and phi were positive: double w[4]; - w[0] = r[XZ]; w[1] = r[ZX]; w[2] = r[YZ]; w[3] = -r[ZY]; + w[0] = r[kXZ]; w[1] = r[kZX]; w[2] = r[kYZ]; w[3] = -r[kZY]; // find biggest relevant term, which is the best one to use in correcting. double maxw = std::fabs(w[0]); @@ -187,15 +186,18 @@ void convert( Rotation3D const & from, EulerAngles & to) } // convert to EulerAngles +//------------------------------------------------------------------------ void convert( Rotation3D const & from, Quaternion & to) { + // conversion from Rotation3D to Quaternion + double m[9]; from.GetComponents(m, m+9); - const double d0 = m[XX] + m[YY] + m[ZZ]; - const double d1 = + m[XX] - m[YY] - m[ZZ]; - const double d2 = - m[XX] + m[YY] - m[ZZ]; - const double d3 = - m[XX] - m[YY] + m[ZZ]; + const double d0 = m[kXX] + m[kYY] + m[kZZ]; + const double d1 = + m[kXX] - m[kYY] - m[kZZ]; + const double d2 = - m[kXX] + m[kYY] - m[kZZ]; + const double d3 = - m[kXX] - m[kYY] + m[kZZ]; // these are related to the various q^2 values; // choose the largest to avoid dividing two small numbers and losing accuracy. @@ -203,36 +205,36 @@ void convert( Rotation3D const & from, Quaternion & to) if ( d0 >= d1 && d0 >= d2 && d0 >= d3 ) { const double q0 = .5*std::sqrt(1+d0); const double f = .25/q0; - const double q1 = f*(m[ZY]-m[YZ]); - const double q2 = f*(m[XZ]-m[ZX]); - const double q3 = f*(m[YX]-m[XY]); + const double q1 = f*(m[kZY]-m[kYZ]); + const double q2 = f*(m[kXZ]-m[kZX]); + const double q3 = f*(m[kYX]-m[kXY]); to.SetComponents(q0,q1,q2,q3); to.Rectify(); return; } else if ( d1 >= d2 && d1 >= d3 ) { const double q1 = .5*std::sqrt(1+d1); const double f = .25/q1; - const double q0 = f*(m[ZY]-m[YZ]); - const double q2 = f*(m[XY]+m[YX]); - const double q3 = f*(m[XZ]+m[ZX]); + const double q0 = f*(m[kZY]-m[kYZ]); + const double q2 = f*(m[kXY]+m[kYX]); + const double q3 = f*(m[kXZ]+m[kZX]); to.SetComponents(q0,q1,q2,q3); to.Rectify(); return; } else if ( d2 >= d3 ) { const double q2 = .5*std::sqrt(1+d2); const double f = .25/q2; - const double q0 = f*(m[XZ]-m[ZX]); - const double q1 = f*(m[XY]+m[YX]); - const double q3 = f*(m[YZ]+m[ZY]); + const double q0 = f*(m[kXZ]-m[kZX]); + const double q1 = f*(m[kXY]+m[kYX]); + const double q3 = f*(m[kYZ]+m[kZY]); to.SetComponents(q0,q1,q2,q3); to.Rectify(); return; } else { const double q3 = .5*std::sqrt(1+d3); const double f = .25/q3; - const double q0 = f*(m[YX]-m[XY]); - const double q1 = f*(m[XZ]+m[ZX]); - const double q2 = f*(m[YZ]+m[ZY]); + const double q0 = f*(m[kYX]-m[kXY]); + const double q1 = f*(m[kXZ]+m[kZX]); + const double q2 = f*(m[kYZ]+m[kZY]); to.SetComponents(q0,q1,q2,q3); to.Rectify(); return; @@ -246,6 +248,8 @@ void convert( Rotation3D const & from, Quaternion & to) void convert( AxisAngle const & from, Rotation3D & to) { + // conversion from AxixAngle to Rotation3D + const double sinDelta = std::sin( from.Angle() ); const double cosDelta = std::cos( from.Angle() ); const double oneMinusCosDelta = 1.0 - cosDelta; @@ -257,25 +261,26 @@ void convert( AxisAngle const & from, Rotation3D & to) double m[9]; - m[XX] = oneMinusCosDelta * uX * uX + cosDelta; - m[XY] = oneMinusCosDelta * uX * uY - sinDelta * uZ; - m[XZ] = oneMinusCosDelta * uX * uZ + sinDelta * uY; + m[kXX] = oneMinusCosDelta * uX * uX + cosDelta; + m[kXY] = oneMinusCosDelta * uX * uY - sinDelta * uZ; + m[kXZ] = oneMinusCosDelta * uX * uZ + sinDelta * uY; - m[YX] = oneMinusCosDelta * uY * uX + sinDelta * uZ; - m[YY] = oneMinusCosDelta * uY * uY + cosDelta; - m[YZ] = oneMinusCosDelta * uY * uZ - sinDelta * uX; + m[kYX] = oneMinusCosDelta * uY * uX + sinDelta * uZ; + m[kYY] = oneMinusCosDelta * uY * uY + cosDelta; + m[kYZ] = oneMinusCosDelta * uY * uZ - sinDelta * uX; - m[ZX] = oneMinusCosDelta * uZ * uX - sinDelta * uY; - m[ZY] = oneMinusCosDelta * uZ * uY + sinDelta * uX; - m[ZZ] = oneMinusCosDelta * uZ * uZ + cosDelta; + m[kZX] = oneMinusCosDelta * uZ * uX - sinDelta * uY; + m[kZY] = oneMinusCosDelta * uZ * uY + sinDelta * uX; + m[kZZ] = oneMinusCosDelta * uZ * uZ + cosDelta; to.SetComponents(m,m+9); } // convert to Rotation3D void convert( AxisAngle const & from , EulerAngles & to ) { - // TODO better - // temporary make conversion using Rotation3D + // conversion from AxixAngle to EulerAngles + // TODO better : temporary make conversion using Rotation3D + Rotation3D tmp; convert(from,tmp); convert(tmp,to); @@ -283,6 +288,8 @@ void convert( AxisAngle const & from , EulerAngles & to ) void convert( AxisAngle const & from, Quaternion & to) { + // conversion from AxixAngle to Quaternion + double s = std::sin (from.Angle()/2); DisplacementVector3D< Cartesian3D<double> > axis = from.Axis(); @@ -300,6 +307,8 @@ void convert( AxisAngle const & from, Quaternion & to) void convert( EulerAngles const & from, Rotation3D & to) { + // conversion from EulerAngles to Rotation3D + typedef double Scalar; const Scalar sPhi = std::sin( from.Phi() ); const Scalar cPhi = std::cos( from.Phi() ); @@ -316,6 +325,8 @@ void convert( EulerAngles const & from, Rotation3D & to) void convert( EulerAngles const & from, AxisAngle & to) { + // conversion from EulerAngles to AxisAngle + // make converting first to quaternion Quaternion q; convert (from, q); convert (q, to); @@ -323,6 +334,8 @@ void convert( EulerAngles const & from, AxisAngle & to) void convert( EulerAngles const & from, Quaternion & to) { + // conversion from EulerAngles to Quaternion + typedef double Scalar; const Scalar plus = (from.Phi()+from.Psi())/2; const Scalar minus = (from.Phi()-from.Psi())/2; @@ -344,6 +357,8 @@ void convert( EulerAngles const & from, Quaternion & to) void convert( Quaternion const & from, Rotation3D & to) { + // conversion from Quaternion to Rotation3D + const double q0 = from.U(); const double q1 = from.I(); const double q2 = from.J(); @@ -368,6 +383,8 @@ void convert( Quaternion const & from, Rotation3D & to) void convert( Quaternion const & from, AxisAngle & to) { + // conversion from Quaternion to AxisAngle + double u = from.U(); if ( u >= 0 ) { if ( u > 1 ) u = 1; @@ -386,8 +403,10 @@ void convert( Quaternion const & from, AxisAngle & to) void convert( Quaternion const & from, EulerAngles & to ) { + // conversion from Quaternion to EulerAngles // TODO better // temporary make conversion using Rotation3D + Rotation3D tmp; convert(from,tmp); convert(tmp,to); @@ -400,6 +419,8 @@ void convert( Quaternion const & from, EulerAngles & to ) void convert( RotationX const & from, Rotation3D & to) { + // conversion from RotationX to Rotation3D + const double c = from.CosAngle(); const double s = from.SinAngle(); to.SetComponents ( 1, 0, 0, @@ -409,14 +430,17 @@ void convert( RotationX const & from, Rotation3D & to) void convert( RotationX const & from, AxisAngle & to) { + // conversion from RotationX to AxisAngle + DisplacementVector3D< Cartesian3D<double> > axis (1, 0, 0); to.SetComponents ( axis, from.Angle() ); } void convert( RotationX const & from , EulerAngles & to ) { - //TODO better - // temporary make conversion using Rotation3D + // conversion from RotationX to EulerAngles + //TODO better: temporary make conversion using Rotation3D + Rotation3D tmp; convert(from,tmp); convert(tmp,to); @@ -424,6 +448,8 @@ void convert( RotationX const & from , EulerAngles & to ) void convert( RotationX const & from, Quaternion & to) { + // conversion from RotationX to Quaternion + to.SetComponents (std::cos(from.Angle()/2), std::sin(from.Angle()/2), 0, 0); } @@ -434,6 +460,8 @@ void convert( RotationX const & from, Quaternion & to) void convert( RotationY const & from, Rotation3D & to) { + // conversion from RotationY to Rotation3D + const double c = from.CosAngle(); const double s = from.SinAngle(); to.SetComponents ( c, 0, s, @@ -443,14 +471,17 @@ void convert( RotationY const & from, Rotation3D & to) void convert( RotationY const & from, AxisAngle & to) { + // conversion from RotationY to AxisAngle + DisplacementVector3D< Cartesian3D<double> > axis (0, 1, 0); to.SetComponents ( axis, from.Angle() ); } void convert( RotationY const & from, EulerAngles & to ) { - // TODO better - // temporary make conversion using Rotation3D + // conversion from RotationY to EulerAngles + // TODO better: temporary make conversion using Rotation3D + Rotation3D tmp; convert(from,tmp); convert(tmp,to); @@ -458,6 +489,8 @@ void convert( RotationY const & from, EulerAngles & to ) void convert( RotationY const & from, Quaternion & to) { + // conversion from RotationY to Quaternion + to.SetComponents (std::cos(from.Angle()/2), 0, std::sin(from.Angle()/2), 0); } @@ -468,6 +501,8 @@ void convert( RotationY const & from, Quaternion & to) void convert( RotationZ const & from, Rotation3D & to) { + // conversion from RotationZ to Rotation3D + const double c = from.CosAngle(); const double s = from.SinAngle(); to.SetComponents ( c, -s, 0, @@ -477,14 +512,17 @@ void convert( RotationZ const & from, Rotation3D & to) void convert( RotationZ const & from, AxisAngle & to) { + // conversion from RotationZ to AxisAngle + DisplacementVector3D< Cartesian3D<double> > axis (0, 0, 1); to.SetComponents ( axis, from.Angle() ); } void convert( RotationZ const & from , EulerAngles & to ) { - // TODO better - // temporary make conversion using Rotation3D + // conversion from RotationZ to EulerAngles + // TODO better: temporary make conversion using Rotation3D + Rotation3D tmp; convert(from,tmp); convert(tmp,to); @@ -492,6 +530,8 @@ void convert( RotationZ const & from , EulerAngles & to ) void convert( RotationZ const & from, Quaternion & to) { + // conversion from RotationZ to Quaternion + to.SetComponents (0, 0, std::cos(from.Angle()/2), std::sin(from.Angle()/2)); } diff --git a/mathcore/src/3DDistances.cxx b/mathcore/src/3DDistances.cxx index 83c2598822d..0ad80cb90af 100644 --- a/mathcore/src/3DDistances.cxx +++ b/mathcore/src/3DDistances.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: 3DDistances.cxxv 1.0 2005/06/23 12:00:00 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: 3DDistances.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -34,10 +34,10 @@ namespace Math { namespace gv_detail { -enum Rotation3DMatrixIndex -{ XX = 0, XY = 1, XZ = 2 -, YX = 3, YY = 4, YZ = 5 -, ZX = 6, ZY = 7, ZZ = 8 +enum ERotation3DMatrixIndex +{ kXX = 0, kXY = 1, kXZ = 2 +, kYX = 3, kYY = 4, kYZ = 5 +, kZX = 6, kZY = 7, kZZ = 8 }; diff --git a/mathcore/src/AxisAngle.cxx b/mathcore/src/AxisAngle.cxx index f6b5803a105..7f7573844a7 100644 --- a/mathcore/src/AxisAngle.cxx +++ b/mathcore/src/AxisAngle.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: AxisAngle.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ +// @(#)root/mathcore:$Name: $:$Id: AxisAngle.cxx,v 1.2 2005/09/19 09:57:07 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -63,10 +63,10 @@ AxisAngle::Rectify() // ======== Transformation to other Rotation Forms ================== -enum Rotation3DMatrixIndex { - XX = 0, XY = 1, XZ = 2 - , YX = 3, YY = 4, YZ = 5 - , ZX = 6, ZY = 7, ZZ = 8 +enum ERotation3DMatrixIndex { + kXX = 0, kXY = 1, kXZ = 2 + , kYX = 3, kYY = 4, kYZ = 5 + , kZX = 6, kZY = 7, kZZ = 8 }; diff --git a/mathcore/src/AxisAngleXother.cxx b/mathcore/src/AxisAngleXother.cxx index d40cf84cda6..e3821abfb15 100644 --- a/mathcore/src/AxisAngleXother.cxx +++ b/mathcore/src/AxisAngleXother.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: AxisAngleXother.cxxv 1.0 2005/06/23 12:00:00 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: AxisAngleXother.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -31,36 +31,31 @@ namespace ROOT { namespace Math { -AxisAngle -AxisAngle:: -operator * (const Rotation3D & r) const { +AxisAngle AxisAngle::operator * (const Rotation3D & r) const { + // combination with a Rotation3D return operator* ( Quaternion(r) ); } -AxisAngle -AxisAngle:: -operator * (const AxisAngle & a) const { +AxisAngle AxisAngle::operator * (const AxisAngle & a) const { + // combination with another AxisAngle return operator* ( Quaternion(a) ); } -AxisAngle -AxisAngle:: -operator * (const EulerAngles & e) const { +AxisAngle AxisAngle::operator * (const EulerAngles & e) const { + // combination with EulerAngles return operator* ( Quaternion(e) ); } -AxisAngle -AxisAngle:: -operator * (const Quaternion & q) const { +AxisAngle AxisAngle::operator * (const Quaternion & q) const { + // combination with Quaternion return AxisAngle ( Quaternion(*this) * q ); } #ifdef MOVE -AxisAngle -AxisAngle:: -operator * (const Quaternion & q) const { +AxisAngle AxisAngle::operator * (const Quaternion & q) const { + // combination with quaternion (not used) const Scalar s1 = std::sin(fAngle/2); const Scalar au = std::cos(fAngle/2); const Scalar ai = s1 * fAxis.X(); @@ -85,9 +80,9 @@ operator * (const Quaternion & q) const { #endif -AxisAngle -AxisAngle:: -operator * (const RotationX & rx) const { +AxisAngle AxisAngle::operator * (const RotationX & rx) const { + // combination with RotationX + const Scalar s1 = std::sin(fAngle/2); const Scalar au = std::cos(fAngle/2); const Scalar ai = s1 * fAxis.X(); @@ -116,9 +111,9 @@ operator * (const RotationX & rx) const { return AxisAngle ( axis, angle ); } -AxisAngle -AxisAngle:: -operator * (const RotationY & ry) const { +AxisAngle AxisAngle::operator * (const RotationY & ry) const { + // combination with RotationY + const Scalar s1 = std::sin(fAngle/2); const Scalar au = std::cos(fAngle/2); const Scalar ai = s1 * fAxis.X(); @@ -147,9 +142,9 @@ operator * (const RotationY & ry) const { return AxisAngle ( axis, angle ); } -AxisAngle -AxisAngle:: -operator * (const RotationZ & rz) const { +AxisAngle AxisAngle::operator * (const RotationZ & rz) const { + // combination with RotationZ + const Scalar s1 = std::sin(fAngle/2); const Scalar au = std::cos(fAngle/2); const Scalar ai = s1 * fAxis.X(); @@ -178,18 +173,15 @@ operator * (const RotationZ & rz) const { return AxisAngle ( axis, angle ); } -AxisAngle -operator*( RotationX const & r, AxisAngle const & a ) { +AxisAngle operator*( RotationX const & r, AxisAngle const & a ) { return AxisAngle(r) * a; // TODO: improve performance } -AxisAngle -operator*( RotationY const & r, AxisAngle const & a ) { +AxisAngle operator*( RotationY const & r, AxisAngle const & a ) { return AxisAngle(r) * a; // TODO: improve performance } -AxisAngle -operator*( RotationZ const & r, AxisAngle const & a ) { +AxisAngle operator*( RotationZ const & r, AxisAngle const & a ) { return AxisAngle(r) * a; // TODO: improve performance } diff --git a/mathcore/src/BitReproducible.cxx b/mathcore/src/BitReproducible.cxx index d72963a0996..cb4c2566132 100644 --- a/mathcore/src/BitReproducible.cxx +++ b/mathcore/src/BitReproducible.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BitReproducible.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ +// @(#)root/mathcore:$Name: $:$Id: BitReproducible.cxx,v 1.2 2005/09/19 09:57:07 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 #include "Math/GenVector/BitReproducible.h" @@ -11,10 +11,11 @@ namespace ROOT { namespace Math { namespace GenVector_detail { -bool BitReproducible::byte_order_known = false; -int BitReproducible::byte_order[8]; +bool BitReproducible::fgByte_order_known = false; +int BitReproducible::fgByte_order[8]; void BitReproducible::Fill_byte_order () { + // Fill_byte_order double x = 1.0; int t30 = 1 << 30; int t22 = 1 << 22; @@ -30,19 +31,19 @@ void BitReproducible::Fill_byte_order () { } // x, in IEEE format, would now be 0x4330060504030201 union DB8 { - unsigned char b[8]; - double d; + unsigned char fB[8]; + double fD; }; DB8 xb; - xb.d = x; + xb.fD = x; int n; - static const int UNSET = -1; + static const int kUNSET = -1; for (n=0; n<8; n++) { - byte_order[n] = UNSET; + fgByte_order[n] = kUNSET; } int order; for (n=0; n<8; n++) { - switch ( xb.b[n] ) { + switch ( xb.fB[n] ) { case 0x43: order = 0; break; @@ -71,46 +72,49 @@ void BitReproducible::Fill_byte_order () { throw BitReproducibleException( "Cannot determine byte-ordering of doubles on this system"); } - if (byte_order[n] != UNSET) { + if (fgByte_order[n] != kUNSET) { throw BitReproducibleException( "Confusion in byte-ordering of doubles on this system"); } - byte_order[n] = order; - byte_order_known = true; + fgByte_order[n] = order; + fgByte_order_known = true; } return; } std::string BitReproducible::D2x(double d) { - if ( !byte_order_known ) Fill_byte_order (); + // hex conversion + if ( !fgByte_order_known ) Fill_byte_order (); DB8 db; - db.d = d; + db.fD = d; std::ostringstream ss; for (int i=0; i<8; ++i) { - int k = byte_order[i]; - ss << std::hex << std::setw(2) << std::setfill('0') << (int)db.b[k]; + int k = fgByte_order[i]; + ss << std::hex << std::setw(2) << std::setfill('0') << (int)db.fB[k]; } return ss.str(); } void BitReproducible::Dto2longs(double d, unsigned long& i, unsigned long& j) { - if ( !byte_order_known ) Fill_byte_order (); + // conversion to 2 longs + if ( !fgByte_order_known ) Fill_byte_order (); DB8 db; - db.d = d; - i = ((static_cast<unsigned long>(db.b[byte_order[0]])) << 24) - | ((static_cast<unsigned long>(db.b[byte_order[1]])) << 16) - | ((static_cast<unsigned long>(db.b[byte_order[2]])) << 8) - | ((static_cast<unsigned long>(db.b[byte_order[3]])) ); - j = ((static_cast<unsigned long>(db.b[byte_order[4]])) << 24) - | ((static_cast<unsigned long>(db.b[byte_order[5]])) << 16) - | ((static_cast<unsigned long>(db.b[byte_order[6]])) << 8) - | ((static_cast<unsigned long>(db.b[byte_order[7]])) ); + db.fD = d; + i = ((static_cast<unsigned long>(db.fB[fgByte_order[0]])) << 24) + | ((static_cast<unsigned long>(db.fB[fgByte_order[1]])) << 16) + | ((static_cast<unsigned long>(db.fB[fgByte_order[2]])) << 8) + | ((static_cast<unsigned long>(db.fB[fgByte_order[3]])) ); + j = ((static_cast<unsigned long>(db.fB[fgByte_order[4]])) << 24) + | ((static_cast<unsigned long>(db.fB[fgByte_order[5]])) << 16) + | ((static_cast<unsigned long>(db.fB[fgByte_order[6]])) << 8) + | ((static_cast<unsigned long>(db.fB[fgByte_order[7]])) ); } double BitReproducible::Longs2double (unsigned long i, unsigned long j) { + // conversion longs to double DB8 db; unsigned char bytes[8]; - if ( !byte_order_known ) Fill_byte_order (); + if ( !fgByte_order_known ) Fill_byte_order (); bytes[0] = static_cast<unsigned char>((i >> 24) & 0xFF); bytes[1] = static_cast<unsigned char>((i >> 16) & 0xFF); bytes[2] = static_cast<unsigned char>((i >> 8) & 0xFF); @@ -120,9 +124,9 @@ double BitReproducible::Longs2double (unsigned long i, unsigned long j) { bytes[6] = static_cast<unsigned char>((j >> 8) & 0xFF); bytes[7] = static_cast<unsigned char>((j ) & 0xFF); for (int k=0; k<8; ++k) { - db.b[byte_order[k]] = bytes[k]; + db.fB[fgByte_order[k]] = bytes[k]; } - return db.d; + return db.fD; } } // namespace _GenVector_detail diff --git a/mathcore/src/Boost.cxx b/mathcore/src/Boost.cxx index f58f0358787..a2a7b3a5edf 100644 --- a/mathcore/src/Boost.cxx +++ b/mathcore/src/Boost.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Boost.cxx,v 1.3 2005/12/08 15:52:41 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Boost.cxx,v 1.4 2005/12/08 21:56:39 moneta Exp $ // Authors: M. Fischler 2005 /********************************************************************** @@ -65,15 +65,16 @@ namespace ROOT { namespace Math { void Boost::SetIdentity() { - fM[XX] = 1.0; fM[XY] = 0.0; fM[XZ] = 0.0; fM[XT] = 0.0; - fM[YY] = 1.0; fM[YZ] = 0.0; fM[YT] = 0.0; - fM[ZZ] = 1.0; fM[ZT] = 0.0; - fM[TT] = 1.0; + // set identity boost + fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; fM[kXT] = 0.0; + fM[kYY] = 1.0; fM[kYZ] = 0.0; fM[kYT] = 0.0; + fM[kZZ] = 1.0; fM[kZT] = 0.0; + fM[kTT] = 1.0; } -void -Boost::SetComponents (Scalar bx, Scalar by, Scalar bz) { +void Boost::SetComponents (Scalar bx, Scalar by, Scalar bz) { + // set the boost beta as 3 components Scalar bp2 = bx*bx + by*by + bz*bz; if (bp2 >= 1) { GenVector_exception e ( @@ -84,57 +85,56 @@ Boost::SetComponents (Scalar bx, Scalar by, Scalar bz) { } Scalar gamma = 1.0 / std::sqrt(1.0 - bp2); Scalar bgamma = gamma * gamma / (1.0 + gamma); - fM[XX] = 1.0 + bgamma * bx * bx; - fM[YY] = 1.0 + bgamma * by * by; - fM[ZZ] = 1.0 + bgamma * bz * bz; - fM[XY] = bgamma * bx * by; - fM[XZ] = bgamma * bx * bz; - fM[YZ] = bgamma * by * bz; - fM[XT] = gamma * bx; - fM[YT] = gamma * by; - fM[ZT] = gamma * bz; - fM[TT] = gamma; + fM[kXX] = 1.0 + bgamma * bx * bx; + fM[kYY] = 1.0 + bgamma * by * by; + fM[kZZ] = 1.0 + bgamma * bz * bz; + fM[kXY] = bgamma * bx * by; + fM[kXZ] = bgamma * bx * bz; + fM[kYZ] = bgamma * by * bz; + fM[kXT] = gamma * bx; + fM[kYT] = gamma * by; + fM[kZT] = gamma * bz; + fM[kTT] = gamma; } -void -Boost::GetComponents (Scalar& bx, Scalar& by, Scalar& bz) const { - Scalar gaminv = 1.0/fM[TT]; - bx = fM[XT]*gaminv; - by = fM[YT]*gaminv; - bz = fM[ZT]*gaminv; +void Boost::GetComponents (Scalar& bx, Scalar& by, Scalar& bz) const { + // get beta of the boots as 3 components + Scalar gaminv = 1.0/fM[kTT]; + bx = fM[kXT]*gaminv; + by = fM[kYT]*gaminv; + bz = fM[kZT]*gaminv; } DisplacementVector3D< Cartesian3D<Boost::Scalar> > Boost::BetaVector() const { - Scalar gaminv = 1.0/fM[TT]; + // get boost beta vector + Scalar gaminv = 1.0/fM[kTT]; return DisplacementVector3D< Cartesian3D<Scalar> > - ( fM[XT]*gaminv, fM[YT]*gaminv, fM[ZT]*gaminv ); + ( fM[kXT]*gaminv, fM[kYT]*gaminv, fM[kZT]*gaminv ); } -void -Boost::GetLorentzRotation (Scalar r[]) const { - r[LXX] = fM[XX]; r[LXY] = fM[XY]; r[LXZ] = fM[XZ]; r[LXT] = fM[XT]; - r[LYX] = fM[XY]; r[LYY] = fM[YY]; r[LYZ] = fM[YZ]; r[LYT] = fM[YT]; - r[LZX] = fM[XZ]; r[LZY] = fM[YZ]; r[LZZ] = fM[ZZ]; r[LZT] = fM[ZT]; - r[LTX] = fM[XT]; r[LTY] = fM[YT]; r[LTZ] = fM[ZT]; r[LTT] = fM[TT]; +void Boost::GetLorentzRotation (Scalar r[]) const { + // get Lorentz rotation corresponding to this boost as an array of 16 values + r[kLXX] = fM[kXX]; r[kLXY] = fM[kXY]; r[kLXZ] = fM[kXZ]; r[kLXT] = fM[kXT]; + r[kLYX] = fM[kXY]; r[kLYY] = fM[kYY]; r[kLYZ] = fM[kYZ]; r[kLYT] = fM[kYT]; + r[kLZX] = fM[kXZ]; r[kLZY] = fM[kYZ]; r[kLZZ] = fM[kZZ]; r[kLZT] = fM[kZT]; + r[kLTX] = fM[kXT]; r[kLTY] = fM[kYT]; r[kLTZ] = fM[kZT]; r[kLTT] = fM[kTT]; } -void -Boost:: -Rectify() { +void Boost::Rectify() { // Assuming the representation of this is close to a true Lorentz Rotation, // but may have drifted due to round-off error from many operations, // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation // again. - if (fM[TT] <= 0) { + if (fM[kTT] <= 0) { GenVector_exception e ( "Attempt to rectify a boost with non-positive gamma"); Throw(e); return; } - DisplacementVector3D< Cartesian3D<Scalar> > beta ( fM[XT], fM[YT], fM[ZT] ); - beta /= fM[TT]; + DisplacementVector3D< Cartesian3D<Scalar> > beta ( fM[kXT], fM[kYT], fM[kZT] ); + beta /= fM[kTT]; if ( beta.mag2() >= 1 ) { beta /= ( beta.R() * ( 1.0 + 1.0e-16 ) ); } @@ -142,33 +142,31 @@ Rectify() { } LorentzVector< PxPyPzE4D<double> > -Boost:: -operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { +Boost::operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { + // apply bosost to a PxPyPzE LorentzVector Scalar x = v.Px(); Scalar y = v.Py(); Scalar z = v.Pz(); Scalar t = v.E(); return LorentzVector< PxPyPzE4D<double> > - ( fM[XX]*x + fM[XY]*y + fM[XZ]*z + fM[XT]*t - , fM[XY]*x + fM[YY]*y + fM[YZ]*z + fM[YT]*t - , fM[XZ]*x + fM[YZ]*y + fM[ZZ]*z + fM[ZT]*t - , fM[XT]*x + fM[YT]*y + fM[ZT]*z + fM[TT]*t ); + ( fM[kXX]*x + fM[kXY]*y + fM[kXZ]*z + fM[kXT]*t + , fM[kXY]*x + fM[kYY]*y + fM[kYZ]*z + fM[kYT]*t + , fM[kXZ]*x + fM[kYZ]*y + fM[kZZ]*z + fM[kZT]*t + , fM[kXT]*x + fM[kYT]*y + fM[kZT]*z + fM[kTT]*t ); } -void -Boost:: -Invert() { - fM[XT] = -fM[XT]; - fM[YT] = -fM[YT]; - fM[ZT] = -fM[ZT]; +void Boost::Invert() { + // invert in place boost (modifying the object) + fM[kXT] = -fM[kXT]; + fM[kYT] = -fM[kYT]; + fM[kZT] = -fM[kZT]; } -Boost -Boost:: -Inverse() const { - Boost I(*this); - I.Invert(); - return I; +Boost Boost::Inverse() const { + // return inverse of boost + Boost tmp(*this); + tmp.Invert(); + return tmp; } diff --git a/mathcore/src/BoostX.cxx b/mathcore/src/BoostX.cxx index fd177c24115..348e89fa7ba 100644 --- a/mathcore/src/BoostX.cxx +++ b/mathcore/src/BoostX.cxx @@ -1,4 +1,4 @@ - // @(#)root/mathcore:$Name: $:$Id: BoostX.cpp,v 1.4 2006/02/04 16:10:26 moneta Exp $ + // @(#)root/mathcore:$Name: $:$Id: BoostX.cxx,v 1.3 2006/02/06 17:22:03 moneta Exp $ // Authors: M. Fischler 2005 /********************************************************************** @@ -29,8 +29,8 @@ namespace ROOT { BoostX::BoostX() : fBeta(0.0), fGamma(1.0) {} -void -BoostX::SetComponents (Scalar bx ) { +void BoostX::SetComponents (Scalar bx ) { + // set component Scalar bp2 = bx*bx; if (bp2 >= 1) { GenVector_exception e ( @@ -42,27 +42,26 @@ BoostX::SetComponents (Scalar bx ) { fGamma = 1.0 / std::sqrt(1.0 - bp2); } -void -BoostX::GetComponents (Scalar& bx) const { +void BoostX::GetComponents (Scalar& bx) const { + // get component bx = fBeta; } DisplacementVector3D< Cartesian3D<BoostX::Scalar> > BoostX::BetaVector() const { + // return beta vector return DisplacementVector3D< Cartesian3D<Scalar> > ( fBeta, 0.0, 0.0 ); } -void -BoostX::GetLorentzRotation (Scalar r[]) const { - r[LXX] = fGamma; r[LXY] = 0.0; r[LXZ] = 0.0; r[LXT] = fGamma*fBeta; - r[LYX] = 0.0; r[LYY] = 1.0; r[LYZ] = 0.0; r[LYT] = 0.0; - r[LZX] = 0.0; r[LZY] = 0.0; r[LZZ] = 1.0; r[LZT] = 0.0; - r[LTX] = fGamma*fBeta; r[LTY] = 0.0; r[LTZ] = 0.0; r[LTT] = fGamma; +void BoostX::GetLorentzRotation (Scalar r[]) const { + // get corresponding LorentzRotation + r[kLXX] = fGamma; r[kLXY] = 0.0; r[kLXZ] = 0.0; r[kLXT] = fGamma*fBeta; + r[kLYX] = 0.0; r[kLYY] = 1.0; r[kLYZ] = 0.0; r[kLYT] = 0.0; + r[kLZX] = 0.0; r[kLZY] = 0.0; r[kLZZ] = 1.0; r[kLZT] = 0.0; + r[kLTX] = fGamma*fBeta; r[kLTY] = 0.0; r[kLTZ] = 0.0; r[kLTT] = fGamma; } -void -BoostX:: -Rectify() { +void BoostX::Rectify() { // Assuming the representation of this is close to a true Lorentz Rotation, // but may have drifted due to round-off error from many operations, // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation @@ -82,8 +81,8 @@ Rectify() { } LorentzVector< PxPyPzE4D<double> > -BoostX:: -operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { +BoostX::operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { + // apply boost to a LV Scalar x = v.Px(); Scalar t = v.E(); return LorentzVector< PxPyPzE4D<double> > @@ -93,16 +92,16 @@ operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { , fGamma*fBeta*x + fGamma*t ); } -void -BoostX:: -Invert() { fBeta = -fBeta; } +void BoostX::Invert() { + // invert + fBeta = -fBeta; +} -BoostX -BoostX:: -Inverse() const { - BoostX I(*this); - I.Invert(); - return I; +BoostX BoostX::Inverse() const { + // return an inverse boostX + BoostX tmp(*this); + tmp.Invert(); + return tmp; } // ========== I/O ===================== diff --git a/mathcore/src/BoostY.cxx b/mathcore/src/BoostY.cxx index f9fab366847..c67e00978e0 100644 --- a/mathcore/src/BoostY.cxx +++ b/mathcore/src/BoostY.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BoostY.cpp,v 1.4 2006/02/04 16:10:26 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: BoostY.cxx,v 1.3 2006/02/06 17:22:03 moneta Exp $ // Authors: M. Fischler 2005 /********************************************************************** @@ -29,8 +29,8 @@ namespace ROOT { BoostY::BoostY() : fBeta(0.0), fGamma(1.0) {} -void -BoostY::SetComponents (Scalar by) { +void BoostY::SetComponents (Scalar by) { + // set component Scalar bp2 = by*by; if (bp2 >= 1) { GenVector_exception e ( @@ -42,27 +42,26 @@ BoostY::SetComponents (Scalar by) { fGamma = 1.0 / std::sqrt(1.0-bp2); } -void -BoostY::GetComponents (Scalar& by) const { +void BoostY::GetComponents (Scalar& by) const { + // get component by = fBeta; } DisplacementVector3D< Cartesian3D<BoostY::Scalar> > BoostY::BetaVector() const { + // return beta vector return DisplacementVector3D< Cartesian3D<Scalar> > ( 0.0, fBeta, 0.0 ); } -void -BoostY::GetLorentzRotation (Scalar r[]) const { - r[LXX] = 1.0; r[LXY] = 0.0; r[LXZ] = 0.0; r[LXT] = 0.0; - r[LYX] = 0.0; r[LYY] = fGamma; r[LYZ] = 0.0; r[LYT] = fGamma*fBeta; - r[LZX] = 0.0; r[LZY] = 0.0; r[LZZ] = 1.0; r[LZT] = 0.0; - r[LTX] = 0.0; r[LTY] = fGamma*fBeta; r[LTZ] = 0.0; r[LTT] = fGamma; +void BoostY::GetLorentzRotation (Scalar r[]) const { + // get corresponding LorentzRotation + r[kLXX] = 1.0; r[kLXY] = 0.0; r[kLXZ] = 0.0; r[kLXT] = 0.0; + r[kLYX] = 0.0; r[kLYY] = fGamma; r[kLYZ] = 0.0; r[kLYT] = fGamma*fBeta; + r[kLZX] = 0.0; r[kLZY] = 0.0; r[kLZZ] = 1.0; r[kLZT] = 0.0; + r[kLTX] = 0.0; r[kLTY] = fGamma*fBeta; r[kLTZ] = 0.0; r[kLTT] = fGamma; } -void -BoostY:: -Rectify() { +void BoostY::Rectify() { // Assuming the representation of this is close to a true Lorentz Rotation, // but may have drifted due to round-off error from many operations, // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation @@ -82,8 +81,8 @@ Rectify() { } LorentzVector< PxPyPzE4D<double> > -BoostY:: -operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { +BoostY::operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { + // apply boost to a LV Scalar y = v.Py(); Scalar t = v.E(); return LorentzVector< PxPyPzE4D<double> > @@ -93,18 +92,16 @@ operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { , fGamma*fBeta*y + fGamma*t ); } -void -BoostY:: -Invert() { +void BoostY::Invert() { + // invert Boost fBeta = -fBeta; } -BoostY -BoostY:: -Inverse() const { - BoostY I(*this); - I.Invert(); - return I; +BoostY BoostY::Inverse() const { + // return inverse + BoostY tmp(*this); + tmp.Invert(); + return tmp; } // ========== I/O ===================== diff --git a/mathcore/src/BoostZ.cxx b/mathcore/src/BoostZ.cxx index b6dedffe0ee..221ef35de0b 100644 --- a/mathcore/src/BoostZ.cxx +++ b/mathcore/src/BoostZ.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: BoostZ.cpp,v 1.4 2006/02/04 16:10:26 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: BoostZ.cxx,v 1.3 2006/02/06 17:22:03 moneta Exp $ // Authors: M. Fischler 2005 /********************************************************************** @@ -29,8 +29,8 @@ namespace ROOT { BoostZ::BoostZ() : fBeta(0.0), fGamma(1.0) {} -void -BoostZ::SetComponents (Scalar bz) { +void BoostZ::SetComponents (Scalar bz) { + // set component Scalar bp2 = bz*bz; if (bp2 >= 1) { GenVector_exception e ( @@ -42,28 +42,27 @@ BoostZ::SetComponents (Scalar bz) { fGamma = 1.0 / std::sqrt(1.0 - bp2); } -void -BoostZ::GetComponents (Scalar& bz) const { +void BoostZ::GetComponents (Scalar& bz) const { + // get component bz = fBeta; } DisplacementVector3D< Cartesian3D<BoostZ::Scalar> > BoostZ::BetaVector() const { + // return beta vector return DisplacementVector3D< Cartesian3D<Scalar> > ( 0.0, 0.0, fBeta ); } -void -BoostZ::GetLorentzRotation (Scalar r[]) const { - r[LXX] = 1.0; r[LXY] = 0.0; r[LXZ] = 0.0; r[LXT] = 0.0 ; - r[LYX] = 0.0; r[LYY] = 1.0; r[LYZ] = 0.0; r[LYT] = 0.0 ; - r[LZX] = 0.0; r[LZY] = 0.0; r[LZZ] = fGamma; r[LZT] = fGamma*fBeta; - r[LTX] = 0.0; r[LTY] = 0.0; r[LTZ] = fGamma*fBeta; r[LTT] = fGamma; +void BoostZ::GetLorentzRotation (Scalar r[]) const { + // get corresponding LorentzRotation + r[kLXX] = 1.0; r[kLXY] = 0.0; r[kLXZ] = 0.0; r[kLXT] = 0.0 ; + r[kLYX] = 0.0; r[kLYY] = 1.0; r[kLYZ] = 0.0; r[kLYT] = 0.0 ; + r[kLZX] = 0.0; r[kLZY] = 0.0; r[kLZZ] = fGamma; r[kLZT] = fGamma*fBeta; + r[kLTX] = 0.0; r[kLTY] = 0.0; r[kLTZ] = fGamma*fBeta; r[kLTT] = fGamma; } -void -BoostZ:: -Rectify() { +void BoostZ::Rectify() { // Assuming the representation of this is close to a true Lorentz Rotation, // but may have drifted due to round-off error from many operations, // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation @@ -83,8 +82,8 @@ Rectify() { } LorentzVector< PxPyPzE4D<double> > -BoostZ:: -operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { +BoostZ::operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { + // apply boost to a LV Scalar z = v.Pz(); Scalar t = v.E(); return LorentzVector< PxPyPzE4D<double> > @@ -94,18 +93,16 @@ operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { , fGamma*fBeta*z + fGamma*t ); } -void -BoostZ:: -Invert() { +void BoostZ::Invert() { + // invert fBeta = -fBeta; } -BoostZ -BoostZ:: -Inverse() const { - BoostZ I(*this); - I.Invert(); - return I; +BoostZ BoostZ::Inverse() const { + // return an inverse boostZ + BoostZ tmp(*this); + tmp.Invert(); + return tmp; } // ========== I/O ===================== diff --git a/mathcore/src/EulerAngles.cxx b/mathcore/src/EulerAngles.cxx index 041454650d5..55035c70ec5 100644 --- a/mathcore/src/EulerAngles.cxx +++ b/mathcore/src/EulerAngles.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: EulerAngles.cxx,v 1.3 2006/02/06 17:22:03 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: EulerAngles.cxx,v 1.4 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Thurs June 9 2005 // -// Last update: $Id: EulerAngles.cxx,v 1.3 2006/02/06 17:22:03 moneta Exp $ +// Last update: $Id: EulerAngles.cxx,v 1.4 2006/04/11 13:06:15 moneta Exp $ // #include "Math/GenVector/EulerAngles.h" @@ -35,9 +35,9 @@ namespace ROOT { // ========== Constructors and Assignment ===================== -void -EulerAngles::Rectify() +void EulerAngles::Rectify() { + // rectify if ( fTheta < 0 || fTheta > Pi() ) { Scalar t = fTheta - std::floor( fTheta/(2*Pi()) ) * 2*Pi(); if ( t <= Pi() ) { @@ -70,44 +70,37 @@ EulerAngles::Rectify() // } -EulerAngles -EulerAngles:: -operator * (const Rotation3D & r) const { +EulerAngles EulerAngles::operator * (const Rotation3D & r) const { + // combine with a Rotation3D return EulerAngles ( Rotation3D(*this) * r ); } -EulerAngles -EulerAngles:: -operator * (const AxisAngle & a) const { +EulerAngles EulerAngles::operator * (const AxisAngle & a) const { + // combine with a AxisAngle return EulerAngles ( Quaternion(*this) * Quaternion(a) ); } -EulerAngles -EulerAngles:: -operator * (const EulerAngles & e) const { +EulerAngles EulerAngles::operator * (const EulerAngles & e) const { + // combine with a EulerAngles return EulerAngles ( Quaternion(*this) * Quaternion(e) ); } -EulerAngles -EulerAngles:: -operator * (const Quaternion & q) const { +EulerAngles EulerAngles::operator * (const Quaternion & q) const { + // combination with a Quaternion return EulerAngles ( Quaternion(*this) * q ); } -EulerAngles -EulerAngles:: -operator * (const RotationX & r) const { +EulerAngles EulerAngles::operator * (const RotationX & r) const { + // combine with a RotationX return EulerAngles ( Quaternion(*this) * r ); } -EulerAngles -EulerAngles:: -operator * (const RotationY & r) const { +EulerAngles EulerAngles::operator * (const RotationY & r) const { + // combine with a RotationY return EulerAngles ( Quaternion(*this) * r ); } -EulerAngles -EulerAngles:: -operator * (const RotationZ & r) const { +EulerAngles EulerAngles::operator * (const RotationZ & r) const { + // combine with a RotationZ // TODO -- this can be made much faster because it merely adds // the r.Angle() to phi. Scalar newPhi = fPhi + r.Angle(); @@ -117,13 +110,11 @@ operator * (const RotationZ & r) const { return EulerAngles ( newPhi, fTheta, fPsi ); } -EulerAngles -operator * ( RotationX const & r, EulerAngles const & e ) { +EulerAngles operator * ( RotationX const & r, EulerAngles const & e ) { return EulerAngles(r) * e; // TODO: improve performance } -EulerAngles -operator * ( RotationY const & r, EulerAngles const & e ) { +EulerAngles operator * ( RotationY const & r, EulerAngles const & e ) { return EulerAngles(r) * e; // TODO: improve performance } diff --git a/mathcore/src/LorentzRotation.cxx b/mathcore/src/LorentzRotation.cxx index 71abeb7cfd8..67992d43ffd 100644 --- a/mathcore/src/LorentzRotation.cxx +++ b/mathcore/src/LorentzRotation.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: LorentzRotation.cxx,v 1.3 2005/10/18 09:13:34 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: LorentzRotation.cxx,v 1.4 2005/12/08 15:52:41 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -34,98 +34,105 @@ namespace ROOT { namespace Math { LorentzRotation::LorentzRotation() { - fM[XX] = 1.0; fM[XY] = 0.0; fM[XZ] = 0.0; fM[XT] = 0.0; - fM[YX] = 0.0; fM[YY] = 1.0; fM[YZ] = 0.0; fM[YT] = 0.0; - fM[ZX] = 0.0; fM[ZY] = 0.0; fM[ZZ] = 1.0; fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + // constructor of an identity LR + fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; fM[kXT] = 0.0; + fM[kYX] = 0.0; fM[kYY] = 1.0; fM[kYZ] = 0.0; fM[kYT] = 0.0; + fM[kZX] = 0.0; fM[kZY] = 0.0; fM[kZZ] = 1.0; fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(Rotation3D const & r) { - r.GetComponents ( fM[XX], fM[XY], fM[XZ], - fM[YX], fM[YY], fM[YZ], - fM[ZX], fM[ZY], fM[ZZ] ); - fM[XT] = 0.0; - fM[YT] = 0.0; - fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + // construct from Rotation3D + r.GetComponents ( fM[kXX], fM[kXY], fM[kXZ], + fM[kYX], fM[kYY], fM[kYZ], + fM[kZX], fM[kZY], fM[kZZ] ); + fM[kXT] = 0.0; + fM[kYT] = 0.0; + fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(AxisAngle const & a) { + // construct from AxisAngle const Rotation3D r(a); - r.GetComponents ( fM[XX], fM[XY], fM[XZ], - fM[YX], fM[YY], fM[YZ], - fM[ZX], fM[ZY], fM[ZZ] ); - fM[XT] = 0.0; - fM[YT] = 0.0; - fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + r.GetComponents ( fM[kXX], fM[kXY], fM[kXZ], + fM[kYX], fM[kYY], fM[kYZ], + fM[kZX], fM[kZY], fM[kZZ] ); + fM[kXT] = 0.0; + fM[kYT] = 0.0; + fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(EulerAngles const & e) { + // construct from EulerAngles const Rotation3D r(e); - r.GetComponents ( fM[XX], fM[XY], fM[XZ], - fM[YX], fM[YY], fM[YZ], - fM[ZX], fM[ZY], fM[ZZ] ); - fM[XT] = 0.0; - fM[YT] = 0.0; - fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + r.GetComponents ( fM[kXX], fM[kXY], fM[kXZ], + fM[kYX], fM[kYY], fM[kYZ], + fM[kZX], fM[kZY], fM[kZZ] ); + fM[kXT] = 0.0; + fM[kYT] = 0.0; + fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(Quaternion const & q) { + // construct from Quaternion const Rotation3D r(q); - r.GetComponents ( fM[XX], fM[XY], fM[XZ], - fM[YX], fM[YY], fM[YZ], - fM[ZX], fM[ZY], fM[ZZ] ); - fM[XT] = 0.0; - fM[YT] = 0.0; - fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + r.GetComponents ( fM[kXX], fM[kXY], fM[kXZ], + fM[kYX], fM[kYY], fM[kYZ], + fM[kZX], fM[kZY], fM[kZZ] ); + fM[kXT] = 0.0; + fM[kYT] = 0.0; + fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(RotationX const & r) { + // construct from RotationX Scalar s = r.SinAngle(); Scalar c = r.CosAngle(); - fM[XX] = 1.0; fM[XY] = 0.0; fM[XZ] = 0.0; fM[XT] = 0.0; - fM[YX] = 0.0; fM[YY] = c ; fM[YZ] = -s ; fM[YT] = 0.0; - fM[ZX] = 0.0; fM[ZY] = s ; fM[ZZ] = c ; fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; fM[kXT] = 0.0; + fM[kYX] = 0.0; fM[kYY] = c ; fM[kYZ] = -s ; fM[kYT] = 0.0; + fM[kZX] = 0.0; fM[kZY] = s ; fM[kZZ] = c ; fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(RotationY const & r) { + // construct from RotationY Scalar s = r.SinAngle(); Scalar c = r.CosAngle(); - fM[XX] = c ; fM[XY] = 0.0; fM[XZ] = s ; fM[XT] = 0.0; - fM[YX] = 0.0; fM[YY] = 1.0; fM[YZ] = 0.0; fM[YT] = 0.0; - fM[ZX] = -s ; fM[ZY] = 0.0; fM[ZZ] = c ; fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + fM[kXX] = c ; fM[kXY] = 0.0; fM[kXZ] = s ; fM[kXT] = 0.0; + fM[kYX] = 0.0; fM[kYY] = 1.0; fM[kYZ] = 0.0; fM[kYT] = 0.0; + fM[kZX] = -s ; fM[kZY] = 0.0; fM[kZZ] = c ; fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } LorentzRotation::LorentzRotation(RotationZ const & r) { + // construct from RotationX Scalar s = r.SinAngle(); Scalar c = r.CosAngle(); - fM[XX] = c ; fM[XY] = -s ; fM[XZ] = 0.0; fM[XT] = 0.0; - fM[YX] = s ; fM[YY] = c ; fM[YZ] = 0.0; fM[YT] = 0.0; - fM[ZX] = 0.0; fM[ZY] = 0.0; fM[ZZ] = 1.0; fM[ZT] = 0.0; - fM[TX] = 0.0; fM[TY] = 0.0; fM[TZ] = 0.0; fM[TT] = 1.0; + fM[kXX] = c ; fM[kXY] = -s ; fM[kXZ] = 0.0; fM[kXT] = 0.0; + fM[kYX] = s ; fM[kYY] = c ; fM[kYZ] = 0.0; fM[kYT] = 0.0; + fM[kZX] = 0.0; fM[kZY] = 0.0; fM[kZZ] = 1.0; fM[kZT] = 0.0; + fM[kTX] = 0.0; fM[kTY] = 0.0; fM[kTZ] = 0.0; fM[kTT] = 1.0; } void -LorentzRotation:: -Rectify() { +LorentzRotation::Rectify() { // Assuming the representation of this is close to a true Lorentz Rotation, // but may have drifted due to round-off error from many operations, // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation // again. typedef LorentzVector< PxPyPzE4D<Scalar> > FourVector; - if (fM[TT] <= 0) { + if (fM[kTT] <= 0) { GenVector_exception e ( "LorentzRotation:Rectify(): Non-positive TT component - cannot rectify"); Throw(e); return; } - FourVector t ( fM[TX], fM[TY], fM[TZ], fM[TT] ); + FourVector t ( fM[kTX], fM[kTY], fM[kTZ], fM[kTT] ); Scalar m2 = t.M2(); if ( m2 <= 0 ) { GenVector_exception e ( @@ -134,7 +141,7 @@ Rectify() { return; } t /= std::sqrt(m2); - FourVector z ( fM[ZX], fM[ZY], fM[ZZ], fM[ZT] ); + FourVector z ( fM[kZX], fM[kZY], fM[kZZ], fM[kZT] ); z = z - z.Dot(t)*t; m2 = z.M2(); if ( m2 >= 0 ) { @@ -145,7 +152,7 @@ Rectify() { return; } z /= std::sqrt(-m2); - FourVector y ( fM[YX], fM[YY], fM[YZ], fM[YT] ); + FourVector y ( fM[kYX], fM[kYY], fM[kYZ], fM[kYT] ); y = y - y.Dot(t)*t - y.Dot(z)*z; m2 = y.M2(); if ( m2 >= 0 ) { @@ -156,7 +163,7 @@ Rectify() { return; } y /= std::sqrt(-m2); - FourVector x ( fM[XX], fM[XY], fM[XZ], fM[XT] ); + FourVector x ( fM[kXX], fM[kXY], fM[kXZ], fM[kXT] ); x = x - x.Dot(t)*t - x.Dot(z)*z - x.Dot(y)*y; m2 = x.M2(); if ( m2 >= 0 ) { @@ -170,62 +177,59 @@ Rectify() { } LorentzVector< PxPyPzE4D<double> > -LorentzRotation:: -operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { +LorentzRotation::operator() (const LorentzVector< PxPyPzE4D<double> > & v) const { + // apply a LR to a 4D LoentzVector Scalar x = v.Px(); Scalar y = v.Py(); Scalar z = v.Pz(); Scalar t = v.E(); return LorentzVector< PxPyPzE4D<double> > - ( fM[XX]*x + fM[XY]*y + fM[XZ]*z + fM[XT]*t - , fM[YX]*x + fM[YY]*y + fM[YZ]*z + fM[YT]*t - , fM[ZX]*x + fM[ZY]*y + fM[ZZ]*z + fM[ZT]*t - , fM[TX]*x + fM[TY]*y + fM[TZ]*z + fM[TT]*t ); + ( fM[kXX]*x + fM[kXY]*y + fM[kXZ]*z + fM[kXT]*t + , fM[kYX]*x + fM[kYY]*y + fM[kYZ]*z + fM[kYT]*t + , fM[kZX]*x + fM[kZY]*y + fM[kZZ]*z + fM[kZT]*t + , fM[kTX]*x + fM[kTY]*y + fM[kTZ]*z + fM[kTT]*t ); } -void -LorentzRotation:: -Invert() { +void LorentzRotation::Invert() { + // invert modifying current content Scalar temp; - temp = fM[XY]; fM[XY] = fM[YX]; fM[YX] = temp; - temp = fM[XZ]; fM[XZ] = fM[ZX]; fM[ZX] = temp; - temp = fM[YZ]; fM[YZ] = fM[ZY]; fM[ZY] = temp; - temp = fM[XT]; fM[XT] = -fM[TX]; fM[TX] = -temp; - temp = fM[YT]; fM[YT] = -fM[TY]; fM[TY] = -temp; - temp = fM[ZT]; fM[ZT] = -fM[TZ]; fM[TZ] = -temp; + temp = fM[kXY]; fM[kXY] = fM[kYX]; fM[kYX] = temp; + temp = fM[kXZ]; fM[kXZ] = fM[kZX]; fM[kZX] = temp; + temp = fM[kYZ]; fM[kYZ] = fM[kZY]; fM[kZY] = temp; + temp = fM[kXT]; fM[kXT] = -fM[kTX]; fM[kTX] = -temp; + temp = fM[kYT]; fM[kYT] = -fM[kTY]; fM[kTY] = -temp; + temp = fM[kZT]; fM[kZT] = -fM[kTZ]; fM[kTZ] = -temp; } -LorentzRotation -LorentzRotation:: -Inverse() const { +LorentzRotation LorentzRotation::Inverse() const { + // return an inverse LR return LorentzRotation - ( fM[XX], fM[YX], fM[ZX], -fM[TX] - , fM[XY], fM[YY], fM[ZY], -fM[TY] - , fM[XZ], fM[YZ], fM[ZZ], -fM[TZ] - , -fM[XT], -fM[YT], -fM[ZT], fM[TT] + ( fM[kXX], fM[kYX], fM[kZX], -fM[kTX] + , fM[kXY], fM[kYY], fM[kZY], -fM[kTY] + , fM[kXZ], fM[kYZ], fM[kZZ], -fM[kTZ] + , -fM[kXT], -fM[kYT], -fM[kZT], fM[kTT] ); } -LorentzRotation -LorentzRotation:: -operator * (const LorentzRotation & r) const { +LorentzRotation LorentzRotation::operator * (const LorentzRotation & r) const { + // combination with another LR return LorentzRotation - ( fM[XX]*r.fM[XX] + fM[XY]*r.fM[YX] + fM[XZ]*r.fM[ZX] + fM[XT]*r.fM[TX] - , fM[XX]*r.fM[XY] + fM[XY]*r.fM[YY] + fM[XZ]*r.fM[ZY] + fM[XT]*r.fM[TY] - , fM[XX]*r.fM[XZ] + fM[XY]*r.fM[YZ] + fM[XZ]*r.fM[ZZ] + fM[XT]*r.fM[TZ] - , fM[XX]*r.fM[XT] + fM[XY]*r.fM[YT] + fM[XZ]*r.fM[ZT] + fM[XT]*r.fM[TT] - , fM[YX]*r.fM[XX] + fM[YY]*r.fM[YX] + fM[YZ]*r.fM[ZX] + fM[YT]*r.fM[TX] - , fM[YX]*r.fM[XY] + fM[YY]*r.fM[YY] + fM[YZ]*r.fM[ZY] + fM[YT]*r.fM[TY] - , fM[YX]*r.fM[XZ] + fM[YY]*r.fM[YZ] + fM[YZ]*r.fM[ZZ] + fM[YT]*r.fM[TZ] - , fM[YX]*r.fM[XT] + fM[YY]*r.fM[YT] + fM[YZ]*r.fM[ZT] + fM[YT]*r.fM[TT] - , fM[ZX]*r.fM[XX] + fM[ZY]*r.fM[YX] + fM[ZZ]*r.fM[ZX] + fM[ZT]*r.fM[TX] - , fM[ZX]*r.fM[XY] + fM[ZY]*r.fM[YY] + fM[ZZ]*r.fM[ZY] + fM[ZT]*r.fM[TY] - , fM[ZX]*r.fM[XZ] + fM[ZY]*r.fM[YZ] + fM[ZZ]*r.fM[ZZ] + fM[ZT]*r.fM[TZ] - , fM[ZX]*r.fM[XT] + fM[ZY]*r.fM[YT] + fM[ZZ]*r.fM[ZT] + fM[ZT]*r.fM[TT] - , fM[TX]*r.fM[XX] + fM[TY]*r.fM[YX] + fM[TZ]*r.fM[ZX] + fM[TT]*r.fM[TX] - , fM[TX]*r.fM[XY] + fM[TY]*r.fM[YY] + fM[TZ]*r.fM[ZY] + fM[TT]*r.fM[TY] - , fM[TX]*r.fM[XZ] + fM[TY]*r.fM[YZ] + fM[TZ]*r.fM[ZZ] + fM[TT]*r.fM[TZ] - , fM[TX]*r.fM[XT] + fM[TY]*r.fM[YT] + fM[TZ]*r.fM[ZT] + fM[TT]*r.fM[TT] + ( fM[kXX]*r.fM[kXX] + fM[kXY]*r.fM[kYX] + fM[kXZ]*r.fM[kZX] + fM[kXT]*r.fM[kTX] + , fM[kXX]*r.fM[kXY] + fM[kXY]*r.fM[kYY] + fM[kXZ]*r.fM[kZY] + fM[kXT]*r.fM[kTY] + , fM[kXX]*r.fM[kXZ] + fM[kXY]*r.fM[kYZ] + fM[kXZ]*r.fM[kZZ] + fM[kXT]*r.fM[kTZ] + , fM[kXX]*r.fM[kXT] + fM[kXY]*r.fM[kYT] + fM[kXZ]*r.fM[kZT] + fM[kXT]*r.fM[kTT] + , fM[kYX]*r.fM[kXX] + fM[kYY]*r.fM[kYX] + fM[kYZ]*r.fM[kZX] + fM[kYT]*r.fM[kTX] + , fM[kYX]*r.fM[kXY] + fM[kYY]*r.fM[kYY] + fM[kYZ]*r.fM[kZY] + fM[kYT]*r.fM[kTY] + , fM[kYX]*r.fM[kXZ] + fM[kYY]*r.fM[kYZ] + fM[kYZ]*r.fM[kZZ] + fM[kYT]*r.fM[kTZ] + , fM[kYX]*r.fM[kXT] + fM[kYY]*r.fM[kYT] + fM[kYZ]*r.fM[kZT] + fM[kYT]*r.fM[kTT] + , fM[kZX]*r.fM[kXX] + fM[kZY]*r.fM[kYX] + fM[kZZ]*r.fM[kZX] + fM[kZT]*r.fM[kTX] + , fM[kZX]*r.fM[kXY] + fM[kZY]*r.fM[kYY] + fM[kZZ]*r.fM[kZY] + fM[kZT]*r.fM[kTY] + , fM[kZX]*r.fM[kXZ] + fM[kZY]*r.fM[kYZ] + fM[kZZ]*r.fM[kZZ] + fM[kZT]*r.fM[kTZ] + , fM[kZX]*r.fM[kXT] + fM[kZY]*r.fM[kYT] + fM[kZZ]*r.fM[kZT] + fM[kZT]*r.fM[kTT] + , fM[kTX]*r.fM[kXX] + fM[kTY]*r.fM[kYX] + fM[kTZ]*r.fM[kZX] + fM[kTT]*r.fM[kTX] + , fM[kTX]*r.fM[kXY] + fM[kTY]*r.fM[kYY] + fM[kTZ]*r.fM[kZY] + fM[kTT]*r.fM[kTY] + , fM[kTX]*r.fM[kXZ] + fM[kTY]*r.fM[kYZ] + fM[kTZ]*r.fM[kZZ] + fM[kTT]*r.fM[kTZ] + , fM[kTX]*r.fM[kXT] + fM[kTY]*r.fM[kYT] + fM[kTZ]*r.fM[kZT] + fM[kTT]*r.fM[kTT] ); } diff --git a/mathcore/src/Plane3D.cxx b/mathcore/src/Plane3D.cxx index 12551a03aa2..91f69ab656e 100644 --- a/mathcore/src/Plane3D.cxx +++ b/mathcore/src/Plane3D.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Plane3D.cxx,v 1.2 2005/12/03 15:15:11 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Plane3D.cxx,v 1.3 2006/05/26 15:10:39 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -69,8 +69,8 @@ Scalar Plane3D::Distance(const XYZPoint & p) const { return fA*p.X() + fB*p.Y() + fC*p.Z() + fD; } -// normalize the plane void Plane3D::Normalize() { +// normalize the plane Scalar s = std::sqrt( fA*fA + fB*fB + fC*fC ); // what to do if s = 0 ?? if ( s == 0) { fD = 0; return; } diff --git a/mathcore/src/Quaternion.cxx b/mathcore/src/Quaternion.cxx index f45e966268f..7bb8089c410 100644 --- a/mathcore/src/Quaternion.cxx +++ b/mathcore/src/Quaternion.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Quaternion.cxxv 1.0 2005/06/23 12:00:00 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Quaternion.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -12,7 +12,7 @@ // // Created by: Mark Fischler Thurs June 9 2005 // -// Last update: $Id: Quaternion.cpp,v 1.3 2005/08/20 00:07:40 fischler Exp $ +// Last update: $Id: Quaternion.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // #include "Math/GenVector/Quaternion.h" @@ -56,9 +56,9 @@ Quaternion::Rectify() // ========== Operations ===================== DisplacementVector3D< Cartesian3D<double> > -Quaternion:: -operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const +Quaternion::operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const { + // apply to a 3D Vector const Scalar alpha = fU*fU - fI*fI - fJ*fJ - fK*fK; const Scalar twoQv = 2*(fI*v.X() + fJ*v.Y() + fK*v.Z()); const Scalar twoU = 2 * fU; @@ -69,9 +69,8 @@ operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const ); } -Quaternion -Quaternion:: -operator * (const Quaternion & q) const { +Quaternion Quaternion::operator * (const Quaternion & q) const { + // combination of rotations return Quaternion ( fU*q.fU - fI*q.fI - fJ*q.fJ - fK*q.fK , fU*q.fI + fI*q.fU + fJ*q.fK - fK*q.fJ @@ -79,27 +78,23 @@ operator * (const Quaternion & q) const { , fU*q.fK + fI*q.fJ - fJ*q.fI + fK*q.fU ); } -Quaternion -Quaternion:: -operator * (const Rotation3D & r) const { +Quaternion Quaternion::operator * (const Rotation3D & r) const { + // combination of rotations return operator* ( Quaternion(r) ); } -Quaternion -Quaternion:: -operator * (const AxisAngle & a) const { +Quaternion Quaternion::operator * (const AxisAngle & a) const { + // combination of rotations return operator* ( Quaternion(a) ); } -Quaternion -Quaternion:: -operator * (const EulerAngles & e) const { +Quaternion Quaternion::operator * (const EulerAngles & e) const { + // combination of rotations return operator* ( Quaternion(e) ); } -Quaternion::Scalar -Quaternion:: -Distance(const Quaternion & q) const { +Quaternion::Scalar Quaternion::Distance(const Quaternion & q) const { + // distance Scalar chordLength = std::fabs(fU*q.fU + fI*q.fI + fJ*q.fJ + fK*q.fK); if (chordLength > 1) chordLength = 1; // in case roundoff fouls us up return acos(chordLength); diff --git a/mathcore/src/QuaternionXaxial.cxx b/mathcore/src/QuaternionXaxial.cxx index 7185933ca3f..f15fc227aa0 100644 --- a/mathcore/src/QuaternionXaxial.cxx +++ b/mathcore/src/QuaternionXaxial.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: QuaternionXaxial.cxxv 1.0 2005/06/23 12:00:00 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: QuaternionXaxial.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -13,7 +13,7 @@ // // Created by: Mark Fischler Tues July 19, 2005 // -// Last update: $Id: QuaternionXaxial.cpp,v 1.2 2005/08/08 21:16:38 wbrown Exp $ +// Last update: $Id: QuaternionXaxial.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ // #include "Math/GenVector/Quaternion.h" @@ -26,9 +26,8 @@ namespace ROOT { // we know that two of the four quaternion components will be zero, // and we exploit that knowledge: -Quaternion -Quaternion:: -operator * (const RotationX & rx) const { +Quaternion Quaternion::operator * (const RotationX & rx) const { + // combination with a RotationX Quaternion q(rx); return Quaternion ( U()*q.U() - I()*q.I() @@ -38,9 +37,8 @@ operator * (const RotationX & rx) const { ); } -Quaternion -Quaternion:: -operator * (const RotationY & ry) const { +Quaternion Quaternion::operator * (const RotationY & ry) const { + // combination with a RotationY Quaternion q(ry); return Quaternion ( U()*q.U() - J()*q.J() @@ -50,9 +48,8 @@ operator * (const RotationY & ry) const { ); } -Quaternion -Quaternion:: -operator * (const RotationZ & rz) const { +Quaternion Quaternion::operator * (const RotationZ & rz) const { + // combination with a RotationZ Quaternion q(rz); return Quaternion ( U()*q.U() - K()*q.K() diff --git a/mathcore/src/Rotation3D.cxx b/mathcore/src/Rotation3D.cxx index 1a3f841d718..502b080fdbc 100644 --- a/mathcore/src/Rotation3D.cxx +++ b/mathcore/src/Rotation3D.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Rotation3D.cxx,v 1.6 2006/02/26 17:20:11 moneta Exp $ +// @(#)root/mathcore:$Name: $:$Id: Rotation3D.cxx,v 1.7 2006/04/11 13:06:15 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -26,17 +26,19 @@ namespace ROOT { // ========== Constructors and Assignment ===================== -Rotation3D::Rotation3D() { - fM[XX] = 1.0; fM[XY] = 0.0; fM[XZ] = 0.0; - fM[YX] = 0.0; fM[YY] = 1.0; fM[YZ] = 0.0; - fM[ZX] = 0.0; fM[ZY] = 0.0; fM[ZZ] = 1.0; +Rotation3D::Rotation3D() +{ + // constructor of a identity rotation + fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; + fM[kYX] = 0.0; fM[kYY] = 1.0; fM[kYZ] = 0.0; + fM[kZX] = 0.0; fM[kZY] = 0.0; fM[kZZ] = 1.0; } void Rotation3D::Rectify() { - + // rectify rotation matrix (make orthogonal) // The "nearest" orthogonal matrix X to a nearly-orthogonal matrix A // (in the sense that X is exaclty orthogonal and the sum of the squares // of the element differences X-A is as small as possible) is given by @@ -44,57 +46,57 @@ Rotation3D::Rectify() // Step 1 -- form symmetric M = A.transpose * A - double M11 = fM[XX]*fM[XX] + fM[YX]*fM[YX] + fM[ZX]*fM[ZX]; - double M12 = fM[XX]*fM[XY] + fM[YX]*fM[YY] + fM[ZX]*fM[ZY]; - double M13 = fM[XX]*fM[XZ] + fM[YX]*fM[YZ] + fM[ZX]*fM[ZZ]; - double M22 = fM[XY]*fM[XY] + fM[YY]*fM[YY] + fM[ZY]*fM[ZY]; - double M23 = fM[XY]*fM[XZ] + fM[YY]*fM[YZ] + fM[ZY]*fM[ZZ]; - double M33 = fM[XZ]*fM[XZ] + fM[YZ]*fM[YZ] + fM[ZZ]*fM[ZZ]; + double m11 = fM[kXX]*fM[kXX] + fM[kYX]*fM[kYX] + fM[kZX]*fM[kZX]; + double m12 = fM[kXX]*fM[kXY] + fM[kYX]*fM[kYY] + fM[kZX]*fM[kZY]; + double m13 = fM[kXX]*fM[kXZ] + fM[kYX]*fM[kYZ] + fM[kZX]*fM[kZZ]; + double m22 = fM[kXY]*fM[kXY] + fM[kYY]*fM[kYY] + fM[kZY]*fM[kZY]; + double m23 = fM[kXY]*fM[kXZ] + fM[kYY]*fM[kYZ] + fM[kZY]*fM[kZZ]; + double m33 = fM[kXZ]*fM[kXZ] + fM[kYZ]*fM[kYZ] + fM[kZZ]*fM[kZZ]; - // Step 2 -- find lower-triangular L such that L * L.transpose = M + // Step 2 -- find lower-triangular U such that U * U.transpose = M - double L11 = std::sqrt(M11); - double L21 = M12/L11; - double L31 = M13/L11; - double L22 = std::sqrt(M22-L21*L21); - double L32 = (M23-M12*M13/M11)/L22; - double L33 = std::sqrt(M33 - L31*L31 - L32*L32); + double u11 = std::sqrt(m11); + double u21 = m12/u11; + double u31 = m13/u11; + double u22 = std::sqrt(m22-u21*u21); + double u32 = (m23-m12*m13/m11)/u22; + double u33 = std::sqrt(m33 - u31*u31 - u32*u32); - // Step 3 -- find K such that K*K = L. K is also lower-triangular + // Step 3 -- find V such that V*V = U. U is also lower-triangular - double K33 = 1/L33; - double K32 = -K33*L32/L22; - double K31 = -(K32*L21+K33*L31)/L11; - double K22 = 1/L22; - double K21 = -K22*L21/L11; - double K11 = 1/L11; + double v33 = 1/u33; + double v32 = -v33*u32/u22; + double v31 = -(v32*u21+v33*u31)/u11; + double v22 = 1/u22; + double v21 = -v22*u21/u11; + double v11 = 1/u11; - // Step 4 -- N = K.transpose * K is inverse(sqrt(A.transpose()*A.inverse())) + // Step 4 -- N = V.transpose * V is inverse(sqrt(A.transpose()*A.inverse())) - double N11 = K11*K11 + K21*K21 + K31*K31; - double N12 = K11*K21 + K21*K22 + K31*K32; - double N13 = K11*K31 + K21*K32 + K31*K33; - double N22 = K21*K21 + K22*K22 + K32*K32; - double N23 = K21*K31 + K22*K32 + K32*K33; - double N33 = K31*K31 + K32*K32 + K33*K33; + double n11 = v11*v11 + v21*v21 + v31*v31; + double n12 = v11*v21 + v21*v22 + v31*v32; + double n13 = v11*v31 + v21*v32 + v31*v33; + double n22 = v21*v21 + v22*v22 + v32*v32; + double n23 = v21*v31 + v22*v32 + v32*v33; + double n33 = v31*v31 + v32*v32 + v33*v33; // Step 5 -- The new matrix is A * N - double A[9]; - std::copy(fM, &fM[9], A); + double mA[9]; + std::copy(fM, &fM[9], mA); - fM[XX] = A[XX]*N11 + A[XY]*N12 + A[XZ]*N13; - fM[XY] = A[XX]*N12 + A[XY]*N22 + A[XZ]*N23; - fM[XZ] = A[XX]*N13 + A[XY]*N23 + A[XZ]*N33; - fM[YX] = A[YX]*N11 + A[YY]*N12 + A[YZ]*N13; - fM[YY] = A[YX]*N12 + A[YY]*N22 + A[YZ]*N23; - fM[YZ] = A[YX]*N13 + A[YY]*N23 + A[YZ]*N33; - fM[ZX] = A[ZX]*N11 + A[ZY]*N12 + A[ZZ]*N13; - fM[ZY] = A[ZX]*N12 + A[ZY]*N22 + A[ZZ]*N23; - fM[ZZ] = A[ZX]*N13 + A[ZY]*N23 + A[ZZ]*N33; + fM[kXX] = mA[kXX]*n11 + mA[kXY]*n12 + mA[kXZ]*n13; + fM[kXY] = mA[kXX]*n12 + mA[kXY]*n22 + mA[kXZ]*n23; + fM[kXZ] = mA[kXX]*n13 + mA[kXY]*n23 + mA[kXZ]*n33; + fM[kYX] = mA[kYX]*n11 + mA[kYY]*n12 + mA[kYZ]*n13; + fM[kYY] = mA[kYX]*n12 + mA[kYY]*n22 + mA[kYZ]*n23; + fM[kYZ] = mA[kYX]*n13 + mA[kYY]*n23 + mA[kYZ]*n33; + fM[kZX] = mA[kZX]*n11 + mA[kZY]*n12 + mA[kZZ]*n13; + fM[kZY] = mA[kZX]*n12 + mA[kZY]*n22 + mA[kZZ]*n23; + fM[kZZ] = mA[kZX]*n13 + mA[kZY]*n23 + mA[kZZ]*n33; } // Rectify() @@ -107,61 +109,60 @@ Rotation3D::Rectify() // operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const // { // return DisplacementVector3D< Cartesian3D<double> > ( -// fM[XX] * v.X() + fM[XY] * v.Y() + fM[XZ] * v.Z() -// , fM[YX] * v.X() + fM[YY] * v.Y() + fM[YZ] * v.Z() -// , fM[ZX] * v.X() + fM[ZY] * v.Y() + fM[ZZ] * v.Z() ); +// fM[kXX] * v.X() + fM[kXY] * v.Y() + fM[kXZ] * v.Z() +// , fM[kYX] * v.X() + fM[kYY] * v.Y() + fM[kYZ] * v.Z() +// , fM[kZX] * v.X() + fM[kZY] * v.Y() + fM[kZZ] * v.Z() ); // } -static inline void swap(double & a, double & b) { double t=b; b=a; a=t; } +static inline void swap(double & a, double & b) { + // swap two values + double t=b; b=a; a=t; +} -void -Rotation3D:: -Invert() { - swap (fM[XY], fM[YX]); - swap (fM[XZ], fM[ZX]); - swap (fM[YZ], fM[ZY]); +void Rotation3D::Invert() { + // invert a rotation + swap (fM[kXY], fM[kYX]); + swap (fM[kXZ], fM[kZX]); + swap (fM[kYZ], fM[kZY]); } -Rotation3D -Rotation3D:: -operator * (const Rotation3D & r) const { +Rotation3D Rotation3D::operator * (const Rotation3D & r) const { + // combine with a rotation of the same type + return Rotation3D ( - fM[XX]*r.fM[XX] + fM[XY]*r.fM[YX] + fM[XZ]*r.fM[ZX] - , fM[XX]*r.fM[XY] + fM[XY]*r.fM[YY] + fM[XZ]*r.fM[ZY] - , fM[XX]*r.fM[XZ] + fM[XY]*r.fM[YZ] + fM[XZ]*r.fM[ZZ] + fM[kXX]*r.fM[kXX] + fM[kXY]*r.fM[kYX] + fM[kXZ]*r.fM[kZX] + , fM[kXX]*r.fM[kXY] + fM[kXY]*r.fM[kYY] + fM[kXZ]*r.fM[kZY] + , fM[kXX]*r.fM[kXZ] + fM[kXY]*r.fM[kYZ] + fM[kXZ]*r.fM[kZZ] - , fM[YX]*r.fM[XX] + fM[YY]*r.fM[YX] + fM[YZ]*r.fM[ZX] - , fM[YX]*r.fM[XY] + fM[YY]*r.fM[YY] + fM[YZ]*r.fM[ZY] - , fM[YX]*r.fM[XZ] + fM[YY]*r.fM[YZ] + fM[YZ]*r.fM[ZZ] + , fM[kYX]*r.fM[kXX] + fM[kYY]*r.fM[kYX] + fM[kYZ]*r.fM[kZX] + , fM[kYX]*r.fM[kXY] + fM[kYY]*r.fM[kYY] + fM[kYZ]*r.fM[kZY] + , fM[kYX]*r.fM[kXZ] + fM[kYY]*r.fM[kYZ] + fM[kYZ]*r.fM[kZZ] - , fM[ZX]*r.fM[XX] + fM[ZY]*r.fM[YX] + fM[ZZ]*r.fM[ZX] - , fM[ZX]*r.fM[XY] + fM[ZY]*r.fM[YY] + fM[ZZ]*r.fM[ZY] - , fM[ZX]*r.fM[XZ] + fM[ZY]*r.fM[YZ] + fM[ZZ]*r.fM[ZZ] + , fM[kZX]*r.fM[kXX] + fM[kZY]*r.fM[kYX] + fM[kZZ]*r.fM[kZX] + , fM[kZX]*r.fM[kXY] + fM[kZY]*r.fM[kYY] + fM[kZZ]*r.fM[kZY] + , fM[kZX]*r.fM[kXZ] + fM[kZY]*r.fM[kYZ] + fM[kZZ]*r.fM[kZZ] ); } -Rotation3D -Rotation3D:: -operator * (const AxisAngle & a) const { +Rotation3D Rotation3D::operator * (const AxisAngle & a) const { + // combine with an AxisAngle rotation return operator* ( Rotation3D(a) ); } -Rotation3D -Rotation3D:: -operator * (const EulerAngles & e) const { +Rotation3D Rotation3D::operator * (const EulerAngles & e) const { + // combine with an EulerAngles rotation return operator* ( Rotation3D(e) ); } -Rotation3D -Rotation3D:: -operator * (const Quaternion & q) const { +Rotation3D Rotation3D::operator * (const Quaternion & q) const { + // combine with a Quaternion rotation return operator* ( Rotation3D(q) ); } std::ostream & operator<< (std::ostream & os, const Rotation3D & r) { // TODO - this will need changing for machine-readable issues - // and even the human readable form needs formatiing improvements + // and even the human readable form needs formatting improvements double m[9]; r.GetComponents(m, m+9); os << "\n" << m[0] << " " << m[1] << " " << m[2]; diff --git a/mathcore/src/Rotation3DxAxial.cxx b/mathcore/src/Rotation3DxAxial.cxx index bdb5e621bd6..707c48728cf 100644 --- a/mathcore/src/Rotation3DxAxial.cxx +++ b/mathcore/src/Rotation3DxAxial.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Rotation3DxAxial.cxx,v 1.1 2005/09/18 17:33:47 brun Exp $ +// @(#)root/mathcore:$Name: $:$Id: Rotation3DxAxial.cxx,v 1.2 2005/12/01 17:17:54 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 #include "Math/GenVector/Rotation3D.h" @@ -11,57 +11,57 @@ namespace ROOT { namespace Math { -Rotation3D -Rotation3D:: -operator * (const RotationX & rx) const { +Rotation3D Rotation3D::operator * (const RotationX & rx) const { + // combination of a Rotation3D with a RotationX Scalar s = rx.SinAngle(); Scalar c = rx.CosAngle(); return Rotation3D ( - fM[XX], fM[XY]*c + fM[XZ]*s, fM[XZ]*c - fM[XY]*s - , fM[YX], fM[YY]*c + fM[YZ]*s, fM[YZ]*c - fM[YY]*s - , fM[ZX], fM[ZY]*c + fM[ZZ]*s, fM[ZZ]*c - fM[ZY]*s + fM[kXX], fM[kXY]*c + fM[kXZ]*s, fM[kXZ]*c - fM[kXY]*s + , fM[kYX], fM[kYY]*c + fM[kYZ]*s, fM[kYZ]*c - fM[kYY]*s + , fM[kZX], fM[kZY]*c + fM[kZZ]*s, fM[kZZ]*c - fM[kZY]*s ); } -Rotation3D -Rotation3D:: -operator * (const RotationY & ry) const { +Rotation3D Rotation3D::operator * (const RotationY & ry) const { + // combination of a Rotation3D with a RotationY Scalar s = ry.SinAngle(); Scalar c = ry.CosAngle(); return Rotation3D ( - fM[XX]*c - fM[XZ]*s, fM[XY], fM[XX]*s + fM[XZ]*c - , fM[YX]*c - fM[YZ]*s, fM[YY], fM[YX]*s + fM[YZ]*c - , fM[ZX]*c - fM[ZZ]*s, fM[ZY], fM[ZX]*s + fM[ZZ]*c + fM[kXX]*c - fM[kXZ]*s, fM[kXY], fM[kXX]*s + fM[kXZ]*c + , fM[kYX]*c - fM[kYZ]*s, fM[kYY], fM[kYX]*s + fM[kYZ]*c + , fM[kZX]*c - fM[kZZ]*s, fM[kZY], fM[kZX]*s + fM[kZZ]*c ); } -Rotation3D -Rotation3D:: -operator * (const RotationZ & rz) const { +Rotation3D Rotation3D::operator * (const RotationZ & rz) const { + // combination of a Rotation3D with a RotationZ Scalar s = rz.SinAngle(); Scalar c = rz.CosAngle(); return Rotation3D ( - fM[XX]*c + fM[XY]*s, fM[XY]*c - fM[XX]*s, fM[XZ] - , fM[YX]*c + fM[YY]*s, fM[YY]*c - fM[YX]*s, fM[YZ] - , fM[ZX]*c + fM[ZY]*s, fM[ZY]*c - fM[ZX]*s, fM[ZZ] + fM[kXX]*c + fM[kXY]*s, fM[kXY]*c - fM[kXX]*s, fM[kXZ] + , fM[kYX]*c + fM[kYY]*s, fM[kYY]*c - fM[kYX]*s, fM[kYZ] + , fM[kZX]*c + fM[kZY]*s, fM[kZY]*c - fM[kZX]*s, fM[kZZ] ); } Rotation3D operator* (RotationX const & r1, Rotation3D const & r2) { + // combination of a RotationX with a Rotation3D // TODO -- recode for much better efficiency! return Rotation3D(r1)*r2; } Rotation3D operator* (RotationY const & r1, Rotation3D const & r2) { + // combination of a RotationY with a Rotation3D // TODO -- recode for much better efficiency! return Rotation3D(r1)*r2; } Rotation3D operator* (RotationZ const & r1, Rotation3D const & r2) { + // combination of a RotationZ with a Rotation3D // TODO -- recode for much better efficiency! return Rotation3D(r1)*r2; } diff --git a/mathcore/src/Transform3D.cxx b/mathcore/src/Transform3D.cxx index effe08f9829..8d5a4cf3a8a 100644 --- a/mathcore/src/Transform3D.cxx +++ b/mathcore/src/Transform3D.cxx @@ -1,4 +1,4 @@ -// @(#)root/mathcore:$Name: $:$Id: Transform3D.cxx,v 1.7 2006/04/20 14:36:48 rdm Exp $ +// @(#)root/mathcore:$Name: $:$Id: Transform3D.cxx,v 1.8 2006/05/26 15:10:40 moneta Exp $ // Authors: W. Brown, M. Fischler, L. Moneta 2005 /********************************************************************** @@ -138,6 +138,7 @@ void Transform3D::Invert() // get rotations and translations void Transform3D::GetDecomposition ( Rotation3D &r, XYZVector &v) const { + // decompose a trasfomation in a 3D rotation and in a 3D vector (cartesian coordinates) r.SetComponents( fM[kXX], fM[kXY], fM[kXZ], fM[kYX], fM[kYY], fM[kYZ], fM[kZX], fM[kZY], fM[kZZ] ); @@ -170,9 +171,10 @@ XYZVector Transform3D::operator() (const XYZVector & v) const return r(v); } -// combination of transformations Transform3D & Transform3D::operator *= (const Transform3D & t) { +// combination of transformations + SetComponents(fM[kXX]*t.fM[kXX]+fM[kXY]*t.fM[kYX]+fM[kXZ]*t.fM[kZX], fM[kXX]*t.fM[kXY]+fM[kXY]*t.fM[kYY]+fM[kXZ]*t.fM[kZY], fM[kXX]*t.fM[kXZ]+fM[kXY]*t.fM[kYZ]+fM[kXZ]*t.fM[kZZ], @@ -191,17 +193,19 @@ Transform3D & Transform3D::operator *= (const Transform3D & t) return *this; } -//set identity ( identity rodation and zero translation) void Transform3D::SetIdentity() { + //set identity ( identity rotation and zero translation) fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; fM[kDX] = 0.0; fM[kYX] = 0.0; fM[kYY] = 1.0; fM[kYZ] = 0.0; fM[kDY] = 0.0; fM[kZX] = 0.0; fM[kZY] = 0.0; fM[kZZ] = 1.0; fM[kDZ] = 0.0; } -// assign from rotation + translation + void Transform3D::AssignFrom (const Rotation3D & r, const XYZVector & v) { + // assignment from rotation + translation + double rotData[9]; r.GetComponents(rotData, rotData +9); // first raw @@ -223,9 +227,9 @@ void Transform3D::AssignFrom (const Rotation3D & r, const XYZVector & v) } -// assign from a translation only (identity rotations) void Transform3D::AssignFrom(const Rotation3D & r) { + // assign from only a rotation (null translation) double rotData[9]; r.GetComponents(rotData, rotData +9); for (int i = 0; i < 3; ++i) { @@ -236,17 +240,17 @@ void Transform3D::AssignFrom(const Rotation3D & r) } } -// assign from a translation only (identity rotations) void Transform3D::AssignFrom(const XYZVector & v) { + // assign from a translation only (identity rotations) fM[kXX] = 1.0; fM[kXY] = 0.0; fM[kXZ] = 0.0; fM[kDX] = v.X(); fM[kYX] = 0.0; fM[kYY] = 1.0; fM[kYZ] = 0.0; fM[kDY] = v.Y(); fM[kZX] = 0.0; fM[kZY] = 0.0; fM[kZZ] = 1.0; fM[kDZ] = v.Z(); } -/// transformations on a 3D plane Plane3D Transform3D::operator() (const Plane3D & plane) const { + // transformations on a 3D plane XYZVector n = plane.Normal(); // take a point on the plane. Use origin projection on the plane // ( -ad, -bd, -cd) if (a**2 + b**2 + c**2 ) = 1 -- GitLab