CLHEP/Vector/RotationInterfaces.h

// -*- C++ -*-
// CLASSDOC OFF
// ---------------------------------------------------------------------------
// CLASSDOC ON

#ifndef HEP_ROTATION_INTERFACES_H
#define HEP_ROTATION_INTERFACES_H

// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// This contains the definition of two abstract interface classes:
// 
// Hep4RotationInterface 
//	contains all the methods to get attributes of either a
// 	HepLorentzRotation or a HepRotation -- any information 
//	that pertains to a LorentzRotation can also be defined
//	for a HepRotation.(For example, the 4x4 representation
//	would just have 0's in the space-time entries and 1 in
//	the time-time entry.) 
//
// Hep3RotationInterface 
//	inherits from Hep4RotationInterface,  and adds methods
//	which are well-defined only in the case of a Rotation.
//	For example, a 3x3 representation is an attribute only
//	if the generic LorentzRotation involves no boost.
//
// In terms of classes in the ZOOM PhysicsVectors package, 
//	Hep4RotationInterface <--> LorentzTransformationInterface
//	Hep3RotationInterface <--> RotationInterface
//
// Hep4RotationInterface is the base class for:
//	HepLorentzRotation
//	HepBoost
//	HepBoostX
//	HepBoostY
//	HepBoostZ
//
// Hep3RotationInterface is the base class for:
//	HepRotation
//	HepRotationX
//	HepRotationY
//	HepRotationZ
//
// .SS See Also
// Rotation.h, LorentzRotation.h
//
// .SS Author
// Mark Fischler
//

#include "CLHEP/config/CLHEP.h"

#ifdef HEP_NO_INLINE_IN_DECLARATION
#define inline
#endif

#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Vector/LorentzVector.h"
#include "CLHEP/Vector/AxisAngle.h"

struct HepRep3x3;
struct HepRep4x4;
struct HepRep4x4Symmetric;

class HepRotation;


//-******************************
//
// Hep4RotationInterface 
//
//-******************************

class Hep4RotationInterface  {

  // All attributes of shared by HepLorentzRotation, HepBoost, 
  // HepBoostX, HepBoostY, HepBoostZ.  HepRotation, HepRotationX, 
  // HepRotationY, HepRotationZ also share this attribute interface.

public:

  static HepDouble tolerance;        // to determine relative nearness

  // ----------  Accessors:

  //  orthosymplectic 4-vectors:
  inline HepLorentzVector col1() const;
  inline HepLorentzVector col2() const;
  inline HepLorentzVector col3() const;
  inline HepLorentzVector col4() const;
  inline HepLorentzVector row1() const;
  inline HepLorentzVector row2() const;
  inline HepLorentzVector row3() const;
  inline HepLorentzVector row4() const;

  //  individual elements:
  virtual HepDouble xx() const = 0;
  virtual HepDouble xy() const = 0;
  virtual HepDouble xz() const = 0;
  virtual HepDouble xt() const = 0;
  virtual HepDouble yx() const = 0;
  virtual HepDouble yy() const = 0;
  virtual HepDouble yz() const = 0;
  virtual HepDouble yt() const = 0;
  virtual HepDouble zx() const = 0;
  virtual HepDouble zy() const = 0;
  virtual HepDouble zz() const = 0;
  virtual HepDouble zt() const = 0;
  virtual HepDouble tx() const = 0;
  virtual HepDouble ty() const = 0;
  virtual HepDouble tz() const = 0;
  virtual HepDouble tt() const = 0;

  //   4x4 representation:
  virtual HepRep4x4 rep4x4() const;

  // ----------  Operations:
  //   comparisons:

  inline int compare( const Hep4RotationInterface & lt ) const;
  // Dictionary-order comparisons, utilizing the decompose(b,r) method

  //   decomposition:

  virtual void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const =0;
  // Decompose as T= R * B, where R is pure rotation, B is pure boost.

  virtual void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const =0;
  // Decompose as T= B * R, where R is pure rotation, B is pure boost.

  HepBoolean operator == (const Hep4RotationInterface & r) const;
  HepBoolean operator != (const Hep4RotationInterface & r) const;

  //   relative comparison:
  static HepDouble getTolerance();
  static HepDouble setTolerance( HepDouble tol );

  virtual HepDouble norm2() const = 0;
  virtual HepDouble  distance2( const Hep4RotationInterface & lt ) const = 0;
  virtual HepDouble  howNear( const Hep4RotationInterface & lt ) const = 0;
  virtual HepBoolean isNear (const Hep4RotationInterface & lt, 
				   HepDouble epsilon=tolerance) const = 0;

  virtual void rectify() = 0;
  // non-const but logically const correction for accumulated roundoff errors

  // ----------  Apply LorentzTransformations:

  virtual HepLorentzVector operator* ( const HepLorentzVector & w ) const = 0;
  virtual HepLorentzVector operator()( const HepLorentzVector & w ) const = 0;
  // Apply to a 4-vector

  // ----------  I/O:

  virtual HepStd::ostream & print( HepStd::ostream & os ) const;

  enum { ToleranceTicks = 100 };

protected:

  virtual ~Hep4RotationInterface();

};  // Hep4RotationInterface



//-******************************
//
// Hep3RotationInterface 
//
//-******************************

class Hep3RotationInterface : public Hep4RotationInterface {

  // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
  // beyond those available by virtue of being a Hep3RotationInterface.

public:

  //   Euler angles:
  virtual HepDouble getPhi  () const = 0;
  virtual HepDouble getTheta() const = 0;
  virtual HepDouble getPsi  () const = 0;
  virtual HepDouble    phi  () const = 0;
  virtual HepDouble    theta() const = 0;
  virtual HepDouble    psi  () const = 0;
  virtual HepEulerAngles eulerAngles() const = 0;

  //   axis & angle of rotation:
  virtual HepDouble  getDelta() const = 0;
  virtual Hep3Vector getAxis () const = 0;
  virtual HepDouble     delta() const = 0;
  virtual Hep3Vector    axis () const = 0;
  virtual HepAxisAngle axisAngle() const = 0;

  //   orthogonal unit-length vectors:
  inline Hep3Vector rowX() const;
  inline Hep3Vector rowY() const;
  inline Hep3Vector rowZ() const;

  inline Hep3Vector colX() const;
  inline Hep3Vector colY() const;
  inline Hep3Vector colZ() const;

  virtual HepRep3x3 rep3x3() const = 0;
  //   3x3 representation

  //  orthosymplectic 4-vectors treating this as a 4-rotation:
  inline HepLorentzVector col1() const;
  inline HepLorentzVector col2() const;
  inline HepLorentzVector col3() const;
  inline HepLorentzVector col4() const;
  inline HepLorentzVector row1() const;
  inline HepLorentzVector row2() const;
  inline HepLorentzVector row3() const;
  inline HepLorentzVector row4() const;

  //  individual elements treating this as a 4-rotation:
  inline HepDouble xt() const; 
  inline HepDouble yt() const; 
  inline HepDouble zt() const; 
  inline HepDouble tx() const; 
  inline HepDouble ty() const;
  inline HepDouble tz() const;
  inline HepDouble tt() const;

  // ---------- Operations in the Rotation group

  virtual HepRotation operator * ( const Hep3RotationInterface & r ) const = 0;

  // ---------- Application

  virtual HepLorentzVector operator* ( const HepLorentzVector & w ) const = 0;
  virtual HepLorentzVector operator()( const HepLorentzVector & w ) const = 0;
  //   apply to HepLorentzVector

  virtual Hep3Vector operator* ( const Hep3Vector & v ) const = 0;
  virtual Hep3Vector operator()( const Hep3Vector & v ) const = 0;
  //   apply to Hep3Vector

  // ---------- I/O and a helper method

  virtual HepStd::ostream & print( HepStd::ostream & os ) const;

  static HepDouble proper (HepDouble delta);
  // Put an angle into the range of (-PI, PI].  Useful helper method.

protected:

  virtual ~Hep3RotationInterface() = 0;

};  // Hep3RotationInterface


//-***************************
// 3x3 and 4x4 representations
//-***************************

struct HepRep3x3 {

  // -----  Constructors:

  inline HepRep3x3();

  inline HepRep3x3(  HepDouble xx, HepDouble xy, HepDouble xz
                   , HepDouble yx, HepDouble yy, HepDouble yz
                   , HepDouble zx, HepDouble zy, HepDouble zz
                   );

  inline HepRep3x3( const HepDouble * array );
  // construct from an array of doubles, holding the rotation matrix
  // in ROW order (xx, xy, ...)

  inline void setToIdentity();

  // -----  The data members are public:
  HepDouble xx_, xy_, xz_,
            yx_, yy_, yz_,
            zx_, zy_, zz_;

  inline void getArray ( HepDouble * array ) const;
  // fill array with the NINE HepDoubles xx, xy, xz ... zz

};  // HepRep3x3

struct HepRep4x4 {

  // -----  Constructors:
  inline HepRep4x4();

  inline HepRep4x4(  HepDouble xx, HepDouble xy, HepDouble xz, HepDouble xt
                   , HepDouble yx, HepDouble yy, HepDouble yz, HepDouble yt
                   , HepDouble zx, HepDouble zy, HepDouble zz, HepDouble zt
                   , HepDouble tx, HepDouble ty, HepDouble tz, HepDouble tt
                   );

  inline HepRep4x4( const HepRep4x4Symmetric & rep );

  inline HepRep4x4( const HepDouble * array );
  // construct from an array of doubles, holding the transformation matrix
  // in ROW order xx, xy, ...

  inline void setToIdentity();

  // -----  The data members are public:
  HepDouble xx_, xy_, xz_, xt_,
            yx_, yy_, yz_, yt_,
            zx_, zy_, zz_, zt_,
            tx_, ty_, tz_, tt_;
                         
  inline void getArray ( HepDouble * array ) const;
  // fill array with the SIXTEEN HepDoubles xx, xy, xz ... tz, tt

  inline HepBoolean operator==(HepRep4x4 const & r) const;
  inline HepBoolean operator!=(HepRep4x4 const & r) const;


};  // HepRep4x4

struct HepRep4x4Symmetric {

  // -----  Constructors:

  inline HepRep4x4Symmetric();

  inline HepRep4x4Symmetric
	( HepDouble xx, HepDouble xy, HepDouble xz, HepDouble xt
                      , HepDouble yy, HepDouble yz, HepDouble yt
                                    , HepDouble zz, HepDouble zt
                                                  , HepDouble tt );

  inline HepRep4x4Symmetric( const HepDouble * array );
  // construct from an array of doubles, holding the transformation matrix
  // elements in this order:  xx, xy, xz, xt, yy, yz, yt, zz, zt, tt

  inline void setToIdentity();

  // -----  The data members are public:
  HepDouble xx_, xy_, xz_, xt_,
                 yy_, yz_, yt_,
                      zz_, zt_,
                           tt_;

  inline void getArray ( HepDouble * array ) const;
  // fill array with the TEN HepDoubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt

};


//-********************
// Global-scope methods
//-********************

#ifdef NEVER
  inline HepBoolean operator==(const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);
  inline HepBoolean operator!=(const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);
#endif
  inline HepBoolean operator< (const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);
  inline HepBoolean operator<=(const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);
  inline HepBoolean operator> (const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);
  inline HepBoolean operator>=(const Hep4RotationInterface  & lt1, 
			       const Hep4RotationInterface  & lt2);

  inline HepStd::ostream & operator<<( HepStd::ostream & os, 
				       const Hep4RotationInterface & lt );

#ifndef HEP_DEBUG_INLINE
#include "CLHEP/Vector/RotationInterfaces.icc"
#endif

#endif // ROTATION_INTERFACES_H

Generated by GNU enscript 1.6.1.