CLHEP/Vector/TwoVector.h
// -*- C++ -*-
// CLASSDOC OFF
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// Hep2Vector is a general 2-vector class defining vectors in two
// dimension using HepDouble components. It comes from the ZOOM
// PlaneVector class (the PhysicsVectors PlaneVector.h will typedef
// PlaneVector to Hep2Vector).
//
// .SS See Also
// ThreeVector.h
//
// .SS Authors
// John Marraffino and Mark Fischler
//
#ifndef HEP_TWOVECTOR_H
#define HEP_TWOVECTOR_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
#include "CLHEP/Vector/ThreeVector.h"
// Declarations of classes and global methods
class Hep2Vector;
HepStd::ostream & operator << (HepStd::ostream &, const Hep2Vector &);
inline HepDouble operator * (const Hep2Vector & a,const Hep2Vector & b);
inline Hep2Vector operator * (const Hep2Vector & p, HepDouble a);
inline Hep2Vector operator * (HepDouble a, const Hep2Vector & p);
Hep2Vector operator / (const Hep2Vector & p, HepDouble a);
inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b);
inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b);
class Hep2Vector {
public:
enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM_COORDINATES };
// Safe indexing of the coordinates when using with matrices, arrays, etc.
inline Hep2Vector( HepDouble x = 0.0, HepDouble y = 0.0 );
// The constructor.
inline Hep2Vector(const Hep2Vector & p);
// The copy constructor.
explicit Hep2Vector( const Hep3Vector & s);
// "demotion" constructor"
// WARNING -- THIS IGNORES THE Z COMPONENT OF THE Hep3Vector.
// SO IN GENERAL, Hep2Vector(v)==v WILL NOT HOLD!
inline ~Hep2Vector();
// The destructor.
inline HepDouble x() const;
inline HepDouble y() const;
// The components in cartesian coordinate system.
HepDouble operator () (int i) const;
inline HepDouble operator [] (int i) const;
// Get components by index. 0-based.
HepDouble & operator () (int i);
inline HepDouble & operator [] (int i);
// Set components by index. 0-based.
inline void setX(HepDouble x);
inline void setY(HepDouble y);
// Set the components in cartesian coordinate system.
inline HepDouble phi() const;
// The azimuth angle.
inline HepDouble mag2() const;
// The magnitude squared.
inline HepDouble mag() const;
// The magnitude.
inline HepDouble r() const;
// r in polar coordinates (r, phi): equal to mag().
inline void setPhi(HepDouble phi);
// Set phi keeping mag constant.
inline void setMag(HepDouble r);
// Set magnitude keeping phi constant.
inline void setR(HepDouble r);
// Set R keeping phi constant. Same as setMag.
inline void setPolar(HepDouble r, HepDouble phi);
// Set by polar coordinates.
inline Hep2Vector & operator = (const Hep2Vector & p);
// Assignment.
inline HepBoolean operator == (const Hep2Vector & v) const;
inline HepBoolean operator != (const Hep2Vector & v) const;
// Comparisons.
int compare (const Hep2Vector & v) const;
HepBoolean operator > (const Hep2Vector & v) const;
HepBoolean operator < (const Hep2Vector & v) const;
HepBoolean operator>= (const Hep2Vector & v) const;
HepBoolean operator<= (const Hep2Vector & v) const;
// dictionary ordering according to y, then x component
static inline HepDouble getTolerance();
static HepDouble setTolerance(HepDouble tol);
HepDouble howNear (const Hep2Vector &p) const;
HepBoolean isNear (const Hep2Vector & p, HepDouble epsilon=tolerance) const;
HepDouble howParallel (const Hep2Vector &p) const;
HepBoolean isParallel
(const Hep2Vector & p, HepDouble epsilon=tolerance) const;
HepDouble howOrthogonal (const Hep2Vector &p) const;
HepBoolean isOrthogonal
(const Hep2Vector & p, HepDouble epsilon=tolerance) const;
inline Hep2Vector & operator += (const Hep2Vector &p);
// Addition.
inline Hep2Vector & operator -= (const Hep2Vector &p);
// Subtraction.
inline Hep2Vector operator - () const;
// Unary minus.
inline Hep2Vector & operator *= (HepDouble a);
// Scaling with real numbers.
inline Hep2Vector unit() const;
// Unit vector parallel to this.
inline Hep2Vector orthogonal() const;
// Vector orthogonal to this.
inline HepDouble dot(const Hep2Vector &p) const;
// Scalar product.
inline HepDouble angle(const Hep2Vector &) const;
// The angle w.r.t. another 2-vector.
void rotate(HepDouble);
// Rotates the Hep2Vector.
operator Hep3Vector () const;
// Cast a Hep2Vector as a Hep3Vector.
// The remaining methods are friends, thus defined at global scope:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
friend HepStd::ostream & operator<< (HepStd::ostream &, const Hep2Vector &);
// Output to a stream.
inline friend HepDouble operator * (const Hep2Vector & a,
const Hep2Vector & b);
// Scalar product.
inline friend Hep2Vector operator * (const Hep2Vector & p, HepDouble a);
// v*c
inline friend Hep2Vector operator * (HepDouble a, const Hep2Vector & p);
// c*v
friend Hep2Vector operator / (const Hep2Vector & p, HepDouble a);
// v/c
inline friend Hep2Vector operator + (const Hep2Vector & a,
const Hep2Vector & b);
// v1+v2
inline friend Hep2Vector operator - (const Hep2Vector & a,
const Hep2Vector & b);
// v1-v2
enum { ZMpvToleranceTicks = 100 };
private:
HepDouble dx;
HepDouble dy;
// The components.
static HepDouble tolerance;
// default tolerance criterion for isNear() to return true.
}; // Hep2Vector
static const Hep2Vector X_HAT2(1.0, 0.0);
static const Hep2Vector Y_HAT2(0.0, 1.0);
#include "CLHEP/Vector/TwoVector.icc"
#endif /* HEP_TWOVECTOR_H */
Generated by GNU enscript 1.6.1.