CLHEP/Vector/ThreeVector.h

// -*- C++ -*-
// CLASSDOC OFF
// $Id: ThreeVector.h,v 1.20 1999/08/06 10:04:50 evc Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// Hep3Vector is a general 3-vector class defining vectors in three
// dimension using HepDouble components. Rotations of these vectors are
// performed by multiplying with an object of the HepRotation class.
//
// .SS See Also
// LorentzVector.h, Rotation.h, LorentzRotation.h
//
// .SS Authors
// Leif Lonnblad and Anders Nilsson.
//

#ifndef HEP_THREEVECTOR_H
#define HEP_THREEVECTOR_H

#ifdef GNUPRAGMA
#pragma interface
#endif

#include "CLHEP/config/CLHEP.h"
#include "CLHEP/config/iostream.h"

#ifdef HEP_NO_INLINE_IN_DECLARATION
#define inline
#endif

class HepRotation;

class Hep3Vector {

public:

  enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
  // Safe indexing of the coordinates when using with matrices, arrays, etc.
  // (BaBar)

  inline Hep3Vector(HepDouble x = 0.0, HepDouble y = 0.0, HepDouble z = 0.0);
  // The constructor.

  inline Hep3Vector(const Hep3Vector &);
  // The copy constructor.

  inline ~Hep3Vector();
  // The destructor.

  HepDouble operator () (int) const;
  inline HepDouble operator [] (int) const;
  // Get components by index (Geant4).

  HepDouble & operator () (int);
  inline HepDouble & operator [] (int);
  // Set components by index.

  inline HepDouble x() const;
  inline HepDouble y() const;
  inline HepDouble z() const;
  // The components in cartesian coordinate system.

  inline void setX(HepDouble);
  inline void setY(HepDouble);
  inline void setZ(HepDouble);
  // Set the components in cartesian coordinate system.

  inline HepDouble phi() const;
  // The azimuth angle.

  inline HepDouble theta() const;
  // The polar angle.

  inline HepDouble cosTheta() const;
  // Cosine of the polar angle.

  inline HepDouble mag2() const;
  // The magnitude squared (rho^2 in spherical coordinate system).

  inline HepDouble mag() const;
  // The magnitude (rho in spherical coordinate system).

  inline void setPhi(HepDouble);
  // Set phi keeping mag and theta constant (BaBar).

  inline void setTheta(HepDouble);
  // Set theta keeping mag and phi constant (BaBar).

  inline void setMag(HepDouble);
  // Set magnitude keeping theta and phi constant (BaBar).

  inline HepDouble perp2() const;
  // The transverse component squared (R^2 in cylindrical coordinate system).

  inline HepDouble perp() const;
  // The transverse component (R in cylindrical coordinate system).

  inline void setPerp(HepDouble);
  // Set the transverse component keeping phi and z constant.

  inline HepDouble perp2(const Hep3Vector &) const;
  // The transverse component w.r.t. given axis squared.

  inline HepDouble perp(const Hep3Vector &) const;
  // The transverse component w.r.t. given axis.

  inline Hep3Vector & operator = (const Hep3Vector &);
  // Assignment.

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

  inline Hep3Vector & operator += (const Hep3Vector &);
  // Addition.

  inline Hep3Vector & operator -= (const Hep3Vector &);
  // Subtraction.

  inline Hep3Vector operator - () const;
  // Unary minus.

  inline Hep3Vector & operator *= (HepDouble);
  // Scaling with real numbers.

  inline Hep3Vector unit() const;
  // Unit vector parallel to this.

  inline Hep3Vector orthogonal() const;
  // Vector orthogonal to this (Geant4).

  inline HepDouble dot(const Hep3Vector &) const;
  // Scalar product.

  inline Hep3Vector cross(const Hep3Vector &) const;
  // Cross product.

  inline HepDouble angle(const Hep3Vector &) const;
  // The angle w.r.t. another 3-vector.

  HepDouble pseudoRapidity() const;
  // Returns the pseudo-rapidity, i.e. -ln(tan(theta/2))

  void rotateX(HepDouble);
  // Rotates the Hep3Vector around the x-axis.

  void rotateY(HepDouble);
  // Rotates the Hep3Vector around the y-axis.

  void rotateZ(HepDouble);
  // Rotates the Hep3Vector around the z-axis.

  void rotateUz(const Hep3Vector&);
  // Rotates reference frame from Uz to newUz (unit vector) (Geant4).

  void rotate(HepDouble, const Hep3Vector &);
  // Rotates around the axis specified by another Hep3Vector.

  Hep3Vector & operator *= (const HepRotation &);
  Hep3Vector & transform(const HepRotation &);
  // Transformation with a Rotation matrix.

private:

  HepDouble dx, dy, dz;
  // The components.
};

#ifdef HEP_NO_INLINE_IN_DECLARATION
#undef inline
#endif

HepStd::ostream & operator << (HepStd::ostream &, const Hep3Vector &);
// Output to a stream.

HepStd::istream & operator >> (HepStd::istream &, Hep3Vector &);
// Input from a stream.

extern const Hep3Vector HepXHat, HepYHat, HepZHat;

#ifdef HEP_SHORT_NAMES
typedef Hep3Vector Vector3;
typedef Hep3Vector DVector3;
typedef Hep3Vector FVector3;
static const Hep3Vector & xhat = HepXHat;
static const Hep3Vector & yhat = HepYHat;
static const Hep3Vector & zhat = HepZHat;
#endif
typedef Hep3Vector HepThreeVectorD;
typedef Hep3Vector HepThreeVectorF;

#ifdef HEP_DEBUG_INLINE

Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
// Addition of 3-vectors.

Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
// Subtraction of 3-vectors.

HepDouble operator * (const Hep3Vector &, const Hep3Vector &);
// Scalar product of 3-vectors.

Hep3Vector operator * (const Hep3Vector &, HepDouble a);
Hep3Vector operator * (HepDouble a, const Hep3Vector &);
// Scaling of 3-vectors with a real number

#else
#include "CLHEP/Vector/ThreeVector.icc"
#endif

#endif /* HEP_THREEVECTOR_H */

Generated by GNU enscript 1.6.1.