Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4INCL::ThreeVector Class Reference

#include <G4INCLThreeVector.hh>

Public Member Functions

 ThreeVector ()
 
 ThreeVector (G4double ax, G4double ay, G4double az)
 
G4double getX () const
 
G4double getY () const
 
G4double getZ () const
 
G4double perp () const
 
G4double perp2 () const
 
G4double mag () const
 
G4double mag2 () const
 
G4double theta () const
 
G4double phi () const
 
G4double dot (const ThreeVector &v) const
 
ThreeVector vector (const ThreeVector &v) const
 
void setX (G4double ax)
 Set the x coordinate. More...
 
void setY (G4double ay)
 Set the y coordinate. More...
 
void setZ (G4double az)
 Set the z coordinate. More...
 
void operator+= (const ThreeVector &v)
 
ThreeVector operator- () const
 Unary minus operator. More...
 
void operator-= (const ThreeVector &v)
 
template<typename T >
void operator*= (const T &c)
 
template<typename T >
void operator/= (const T &c)
 
ThreeVector operator- (const ThreeVector &v) const
 
ThreeVector operator+ (const ThreeVector &v) const
 
ThreeVector operator/ (const G4double C) const
 
ThreeVector operator* (const G4double C) const
 
void rotate (const G4double angle, const ThreeVector &axis)
 Rotate the vector by a given angle around a given axis. More...
 
std::string print () const
 
std::string dump () const
 

Detailed Description

Definition at line 53 of file G4INCLThreeVector.hh.

Constructor & Destructor Documentation

G4INCL::ThreeVector::ThreeVector ( )
inline

Definition at line 55 of file G4INCLThreeVector.hh.

Referenced by operator*(), operator+(), operator-(), operator/(), and vector().

56  :x(0.0), y(0.0), z(0.0)
57  {}
G4INCL::ThreeVector::ThreeVector ( G4double  ax,
G4double  ay,
G4double  az 
)
inline

Definition at line 59 of file G4INCLThreeVector.hh.

60  :x(ax), y(ay), z(az)
61  {}

Member Function Documentation

G4double G4INCL::ThreeVector::dot ( const ThreeVector v) const
inline
std::string G4INCL::ThreeVector::dump ( ) const
inline

Definition at line 188 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Particle::dump().

188  {
189  std::stringstream ss;
190  ss <<"(vector3 " << x << " " << y << " " << z << ")";
191  return ss.str();
192  }
G4double G4INCL::ThreeVector::getX ( ) const
inline
G4double G4INCL::ThreeVector::getY ( ) const
inline
G4double G4INCL::ThreeVector::getZ ( ) const
inline
G4double G4INCL::ThreeVector::mag ( ) const
inline
G4double G4INCL::ThreeVector::mag2 ( ) const
inline
ThreeVector G4INCL::ThreeVector::operator* ( const G4double  C) const
inline

Definition at line 166 of file G4INCLThreeVector.hh.

References ThreeVector().

166  {
167  return ThreeVector(x*C, y*C, z*C);
168  }
template<typename T >
void G4INCL::ThreeVector::operator*= ( const T &  c)
inline

Definition at line 138 of file G4INCLThreeVector.hh.

References test::c.

Referenced by operator/=().

138  {
139  x *= c;
140  y *= c;
141  z *= c;
142  }
ThreeVector G4INCL::ThreeVector::operator+ ( const ThreeVector v) const
inline

Definition at line 154 of file G4INCLThreeVector.hh.

References ThreeVector().

154  {
155  return ThreeVector(x+v.x, y+v.y, z+v.z);
156  }
void G4INCL::ThreeVector::operator+= ( const ThreeVector v)
inline

Definition at line 120 of file G4INCLThreeVector.hh.

120  {
121  x += v.x;
122  y += v.y;
123  z += v.z;
124  }
ThreeVector G4INCL::ThreeVector::operator- ( ) const
inline

Unary minus operator.

Definition at line 127 of file G4INCLThreeVector.hh.

References ThreeVector().

127  {
128  return ThreeVector(-x,-y,-z);
129  }
ThreeVector G4INCL::ThreeVector::operator- ( const ThreeVector v) const
inline

Definition at line 150 of file G4INCLThreeVector.hh.

References ThreeVector().

150  {
151  return ThreeVector(x-v.x, y-v.y, z-v.z);
152  }
void G4INCL::ThreeVector::operator-= ( const ThreeVector v)
inline

Definition at line 131 of file G4INCLThreeVector.hh.

131  {
132  x -= v.x;
133  y -= v.y;
134  z -= v.z;
135  }
ThreeVector G4INCL::ThreeVector::operator/ ( const G4double  C) const
inline

Divides all components of the vector with a constant number.

Definition at line 161 of file G4INCLThreeVector.hh.

References ThreeVector().

161  {
162  const G4double oneOverC = 1./C;
163  return ThreeVector(x*oneOverC, y*oneOverC, z*oneOverC);
164  }
double G4double
Definition: G4Types.hh:76
template<typename T >
void G4INCL::ThreeVector::operator/= ( const T &  c)
inline

Definition at line 145 of file G4INCLThreeVector.hh.

References test::c, and operator*=().

145  {
146  const G4double oneOverC = 1./c;
147  this->operator*=(oneOverC);
148  }
void operator*=(const T &c)
double G4double
Definition: G4Types.hh:76
G4double G4INCL::ThreeVector::perp ( ) const
inline

Definition at line 67 of file G4INCLThreeVector.hh.

Referenced by G4INCL::DeltaDecayChannel::getFinalState(), and theta().

67 { return std::sqrt(x*x + y*y); }
G4double G4INCL::ThreeVector::perp2 ( ) const
inline

Definition at line 68 of file G4INCLThreeVector.hh.

Referenced by G4INCL::DeltaProductionChannel::getFinalState(), and G4INCL::ElasticChannel::getFinalState().

68 { return x*x + y*y; }
G4double G4INCL::ThreeVector::phi ( ) const
inline

Phi angle

Definition at line 89 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Nucleus::fillEventInfo().

89  {
90  return x == 0.0 && y == 0.0 ? 0.0 : std::atan2(y,x);
91  }
std::string G4INCL::ThreeVector::print ( ) const
inline

Definition at line 182 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Cluster::print(), and G4INCL::Particle::print().

182  {
183  std::stringstream ss;
184  ss <<"(x = " << x << " y = " << y << " z = " << z <<")";
185  return ss.str();
186  }
void G4INCL::ThreeVector::rotate ( const G4double  angle,
const ThreeVector axis 
)
inline

Rotate the vector by a given angle around a given axis.

Parameters
anglethe rotation angle
axisthe rotation axis, which must be a unit vector

Definition at line 175 of file G4INCLThreeVector.hh.

References dot(), and vector().

Referenced by G4INCL::Particle::rotate().

175  {
176  // Use Rodrigues' formula
177  const G4double cos = std::cos(angle);
178  const G4double sin = std::sin(angle);
179  (*this) = (*this) * cos + axis.vector(*this) * sin + axis * (axis.dot(*this)*(1.-cos));
180  }
double G4double
Definition: G4Types.hh:76
void G4INCL::ThreeVector::setX ( G4double  ax)
inline

Set the x coordinate.

Definition at line 112 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Cluster::internalBoostToCM().

112 { x = ax; }
void G4INCL::ThreeVector::setY ( G4double  ay)
inline

Set the y coordinate.

Definition at line 115 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Cluster::internalBoostToCM().

115 { y = ay; }
void G4INCL::ThreeVector::setZ ( G4double  az)
inline

Set the z coordinate.

Definition at line 118 of file G4INCLThreeVector.hh.

Referenced by G4INCL::Cluster::internalBoostToCM().

118 { z = az; }
G4double G4INCL::ThreeVector::theta ( ) const
inline

Theta angle

Definition at line 82 of file G4INCLThreeVector.hh.

References perp().

Referenced by G4INCL::Nucleus::fillEventInfo().

82  {
83  return x == 0.0 && y == 0.0 && z == 0.0 ? 0.0 : std::atan2(perp(),z);
84  }
G4double perp() const
ThreeVector G4INCL::ThreeVector::vector ( const ThreeVector v) const
inline

Vector product.

Definition at line 103 of file G4INCLThreeVector.hh.

References ThreeVector().

Referenced by G4INCL::Particle::getAngularMomentum(), and rotate().

103  {
104  return ThreeVector(
105  y*v.z - z*v.y,
106  z*v.x - x*v.z,
107  x*v.y - y*v.x
108  );
109  }

The documentation for this class was generated from the following file: