CLHEP/Vector/LorentzRotation.h

// -*- C++ -*-
// CLASSDOC OFF
// $Id: LorentzRotation.h,v 1.10 2001/01/18 17:34:10 mf Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// This is the definition of the HepLorentzRotation class for performing 
// Lorentz transformations (rotations and boosts) on objects of the
// HepLorentzVector class.
//
// HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
//
// .SS See Also
// RotationInterfaces.h
// ThreeVector.h, LorentzVector.h
// Rotation.h, Boost.h
//
// .SS Author
// Leif Lonnblad, Mark Fischler

#ifndef HEP_LORENTZROTATION_H
#define HEP_LORENTZROTATION_H

#ifdef GNUPRAGMA
#pragma interface
#endif

#ifdef HEP_NO_INLINE_IN_DECLARATION
#define inline
#endif

#include "CLHEP/Vector/RotationInterfaces.h"
#include "CLHEP/Vector/Rotation.h" 
#include "CLHEP/Vector/Boost.h" 
#include "CLHEP/Vector/LorentzVector.h"

// Declarations of classes and global methods
class HepLorentzRotation;
inline HepLorentzRotation inverseOf ( const Hep4RotationInterface & lt );
HepLorentzRotation operator * (const HepRotation & r,
                                        const HepLorentzRotation & lt);

class HepLorentzRotation : public Hep4RotationInterface {

public:
  // ----------  Identity HepLorentzRotation:

  static const HepLorentzRotation IDENTITY;

  // ----------  Constructors and Assignment:

  inline HepLorentzRotation();
  // Default constructor. Gives a unit matrix.

  virtual HepLorentzRotation & set (const Hep4RotationInterface & r);
  inline  HepLorentzRotation       (const Hep4RotationInterface & r);
  inline  HepLorentzRotation       (const HepLorentzRotation & r);
  // Copy constructor.

  virtual HepLorentzRotation & set (const Hep3RotationInterface & r);
  inline  HepLorentzRotation       (const Hep3RotationInterface & r);
  // Constructor from 3-D rotation.

  inline HepLorentzRotation & operator = (const HepLorentzRotation & m);
  inline HepLorentzRotation & operator = (const Hep4RotationInterface & m);
  // Assignment.

  inline HepLorentzRotation & operator = (const Hep3RotationInterface & m);
  // Assignment from 3-D rotation.

  virtual HepLorentzRotation & set (HepDouble bx, HepDouble by, HepDouble bz);
  virtual HepLorentzRotation & set (const Hep3Vector & p);
  virtual HepLorentzRotation & set (const HepBoost & boost);
  inline  HepLorentzRotation (HepDouble bx, HepDouble by, HepDouble bz);
  inline  HepLorentzRotation (const Hep3Vector & p);
  inline  HepLorentzRotation ( const HepBoost & boost );
  // Constructors giving a Lorentz-boost.

  virtual HepLorentzRotation & set( 
		const HepBoost & B, const Hep3RotationInterface & R );
  inline  HepLorentzRotation (
		const HepBoost & B, const Hep3RotationInterface & R );
  //   supply B and R:  T = B R:

  virtual HepLorentzRotation & set( 
		const Hep3RotationInterface & R, const HepBoost & B );
  inline  HepLorentzRotation (
		const Hep3RotationInterface & R, const HepBoost & B );
  //   supply R and B:  T = R B:

  virtual HepLorentzRotation & set( 
	const Hep4RotationInterface & B, const Hep3RotationInterface & R );
  inline  HepLorentzRotation (
	const Hep4RotationInterface & B, const Hep3RotationInterface & R );
  //   supply B and R:  T = B R:

  virtual HepLorentzRotation & set( 
	const Hep3RotationInterface & R, const Hep4RotationInterface & B );
  inline  HepLorentzRotation (
	const Hep3RotationInterface & R, const Hep4RotationInterface & B );
  //   supply R and B:  T = R B:

  HepLorentzRotation ( const HepLorentzVector & col1,
		       const HepLorentzVector & col2,
		       const HepLorentzVector & col3,
		       const HepLorentzVector & col4 );
  // Construct from four *orthosymplectic* LorentzVectors for the columns:
	// NOTE:
        //      This constructor, and the two set methods below,
        //      will check that the columns (or rows) form an orthosymplectic
        //      matrix, and will adjust values so that this relation is
        //      as exact as possible.
	//	Orthosymplectic means the dot product USING THE METRIC
	//	of two different coumns will be 0, and of a column with
	//	itself will be one. 

  virtual HepLorentzRotation & set( const HepLorentzVector & col1,
                                    const HepLorentzVector & col2,
                                    const HepLorentzVector & col3,
                                    const HepLorentzVector & col4 );
  //   supply four *orthosymplectic* HepLorentzVectors for the columns

  virtual HepLorentzRotation & setRows( const HepLorentzVector & row1,
                                        const HepLorentzVector & row2,
                                        const HepLorentzVector & row3,
                                        const HepLorentzVector & row4 );
  //   supply four *orthosymplectic* HepLorentzVectors for the columns

  virtual HepLorentzRotation & set( const HepRep4x4 & rep );
  inline  HepLorentzRotation      ( const HepRep4x4 & rep );
  //   supply a HepRep4x4 structure (16 numbers)
  // WARNING:
  //            This constructor and set method will assume the
  //            HepRep4x4 supplied is in fact an orthosymplectic matrix.
  //            No checking or correction is done.  If you are
  //            not certain the matrix is orthosymplectic, break it
  //            into four HepLorentzVector columns and use the form
  //            HepLorentzRotation (col1, col2, col3, col4)

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

  inline HepDouble xx() const;
  inline HepDouble xy() const;
  inline HepDouble xz() const;
  inline HepDouble xt() const;
  inline HepDouble yx() const;
  inline HepDouble yy() const;
  inline HepDouble yz() const;
  inline HepDouble yt() const;
  inline HepDouble zx() const;
  inline HepDouble zy() const;
  inline HepDouble zz() const;
  inline HepDouble zt() const;
  inline HepDouble tx() const;
  inline HepDouble ty() const;
  inline HepDouble tz() const;
  inline HepDouble tt() const;
  // Elements of the matrix.

  inline HepLorentzVector col1() const;
  inline HepLorentzVector col2() const;
  inline HepLorentzVector col3() const;
  inline HepLorentzVector col4() const;
  // orthosymplectic column vectors

  inline HepLorentzVector row1() const;
  inline HepLorentzVector row2() const;
  inline HepLorentzVector row3() const;
  inline HepLorentzVector row4() const;
  // orthosymplectic row vectors

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

  // ------------  Subscripting:

  class HepLorentzRotation_row {
  public:
    inline HepLorentzRotation_row(const HepLorentzRotation &, int);
    inline HepDouble operator [] (int) const;
  private:
    const HepLorentzRotation & rr;
    int ii;
  };
  // Helper class for implemention of C-style subscripting r[i][j] 

  inline const HepLorentzRotation_row operator [] (int) const; 
  // Returns object of the helper class for C-style subscripting r[i][j]

  HepDouble operator () (int, int) const;
  // Fortran-style subscripting: returns (i,j) element of the matrix.

  // ----------  Decomposition:

  virtual void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
          void decompose (HepBoost   & boost, HepRotation  & rotation) const;
  // Find B and R such that L = B*R

  virtual void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
          void decompose (HepRotation  & rotation, HepBoost   & boost) const;
  // Find R and B such that L = R*B 

  // ----------  Comparisons:

  inline HepBoolean operator == (const HepLorentzRotation &) const;
  inline HepBoolean operator != (const HepLorentzRotation &) const;
  // Comparisons.

  inline HepBoolean isIdentity() const;
  // Returns true if the Identity matrix.

  virtual int compare( const Hep4RotationInterface & r  ) const;
  // Dictionary-order comparison.  This is used in
  // operator<, operator>, operator<=, and operator>=, which are inherited.

  virtual HepDouble distance2( const Hep4RotationInterface & lt  ) const;
  // Decomposes L = B*R, returns the sum of distance2 for B and R.

  virtual HepDouble howNear(   const Hep4RotationInterface & lt ) const;

  virtual HepBoolean isNear(   const Hep4RotationInterface & lt,
                                     HepDouble epsilon=tolerance) const;

  // ----------  Properties:

  virtual HepDouble norm2() const;
  // distance2 (IDENTITY), which involves decomposing into B and R and summing 
  // norm2 for the individual B and R parts. 

  virtual void rectify();
  // non-const but logically moot correction for accumulated roundoff errors
        // rectify averages the matrix with the orthotranspose of its actual
        // inverse (absent accumulated roundoff errors, the orthotranspose IS
        // the inverse)); this removes to first order those errors.
        // Then it formally decomposes that, extracts axis and delta for its
	// Rotation part, forms a LorentzRotation from a true HepRotation 
	// with those values of axis and delta, times the true Boost
	// with that boost vector.

  // ---------- Application:

  virtual HepLorentzVector operator()( const HepLorentzVector & w ) const;
  // Transform a Lorentz Vector.             

  inline HepLorentzVector vectorMultiplication(const HepLorentzVector&) const;
  inline HepLorentzVector operator* ( const HepLorentzVector & p ) const;
  // Multiplication with a Lorentz Vector.

  // ---------- Operations in the group of 4-Rotations

  HepLorentzRotation matrixMultiplication(const HepLorentzRotation &) const;

  virtual HepLorentzRotation operator * 
				(const Hep4RotationInterface & lt) const;
  // Product of two Lorentz Rotations (this) * lt - matrix multiplication  

  inline  HepLorentzRotation & operator *= (const Hep4RotationInterface & lt);
  inline  HepLorentzRotation & transform   (const Hep4RotationInterface & lt);
  // Matrix multiplication.
  // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;

  HepLorentzRotation & rotateX(HepDouble delta);
  // Rotation around the x-axis; equivalent to LT = RotationX(delta) * LT

  HepLorentzRotation & rotateY(HepDouble delta);
  // Rotation around the y-axis; equivalent to LT = RotationY(delta) * LT

  HepLorentzRotation & rotateZ(HepDouble delta);
  // Rotation around the z-axis; equivalent to LT = RotationZ(delta) * LT

  inline HepLorentzRotation & rotate(HepDouble delta, const Hep3Vector& axis);
  inline HepLorentzRotation & rotate(HepDouble delta, const Hep3Vector *axis);
  // Rotation around specified vector - LT = Rotation(delta,axis)*LT

  HepLorentzRotation & boostX(HepDouble beta);
  // Pure boost along the x-axis; equivalent to LT = BoostX(beta) * LT

  HepLorentzRotation & boostY(HepDouble beta);
  // Pure boost along the y-axis; equivalent to LT = BoostX(beta) * LT

  HepLorentzRotation & boostZ(HepDouble beta);
  // Pure boost along the z-axis; equivalent to LT = BoostX(beta) * LT

  inline HepLorentzRotation & boost(HepDouble, HepDouble, HepDouble);
  inline HepLorentzRotation & boost(const Hep3Vector &);
  // Lorenz boost.

  inline HepLorentzRotation inverse() const;
  // Return the inverse.

  inline friend HepLorentzRotation inverseOf 
					( const Hep4RotationInterface & lt );
  // global method to invert.

  inline HepLorentzRotation & invert();
  // Inverts the LorentzRotation matrix.

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

  virtual HepStd::ostream & print( HepStd::ostream & os ) const;
  // Aligned six-digit-accurate output of the transformation matrix. 

  friend HepLorentzRotation operator * (const HepRotation & r,
                                        const HepLorentzRotation & lt);
// Compute the product of a HepRotation and a HepLorentzRotation

protected:

  inline HepLorentzRotation
       (HepDouble mxx, HepDouble mxy, HepDouble mxz, HepDouble mxt,
	HepDouble myx, HepDouble myy, HepDouble myz, HepDouble myt,
	HepDouble mzx, HepDouble mzy, HepDouble mzz, HepDouble mzt,
	HepDouble mtx, HepDouble mty, HepDouble mtz, HepDouble mtt);
  // Protected constructor.
  // DOES NOT CHECK FOR VALIDITY AS A LORENTZ TRANSFORMATION.

  inline void setBoost(HepDouble, HepDouble, HepDouble);
  // Set elements according to a boost vector.

  HepDouble mxx, mxy, mxz, mxt,
            myx, myy, myz, myt,
            mzx, mzy, mzz, mzt,
            mtx, mty, mtz, mtt;
  // The matrix elements.

};

#ifdef HEP_NO_INLINE_IN_DECLARATION
#undef inline
#endif

#ifdef HEP_SHORT_NAMES
typedef HepLorentzRotation LRotation;
#endif

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

#endif /* HEP_LORENTZROTATION_H */

Generated by GNU enscript 1.6.1.