Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 set (const G4double ax, const G4double ay, const G4double az)
 Set all the coordinates. 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...
 
ThreeVector anyOrthogonal () const
 Return a vector orthogonal to this. More...
 
std::string print () const
 
std::string dump () const
 

Detailed Description

Definition at line 54 of file G4INCLThreeVector.hh.

Constructor & Destructor Documentation

G4INCL::ThreeVector::ThreeVector ( )
inline

Definition at line 56 of file G4INCLThreeVector.hh.

57  :x(0.0), y(0.0), z(0.0)
58  {}

Here is the caller graph for this function:

G4INCL::ThreeVector::ThreeVector ( G4double  ax,
G4double  ay,
G4double  az 
)
inline

Definition at line 60 of file G4INCLThreeVector.hh.

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

Member Function Documentation

ThreeVector G4INCL::ThreeVector::anyOrthogonal ( ) const
inline

Return a vector orthogonal to this.

Simple algorithm from Hughes and Moeller, J. Graphics Tools 4 (1999) 33.

Definition at line 191 of file G4INCLThreeVector.hh.

191  {
192  if(x<=y && x<=z)
193  return ThreeVector(0., -z, y);
194  else if(y<=x && y<=z)
195  return ThreeVector(-z, 0., x);
196  else
197  return ThreeVector(-y, x, 0.);
198  }

Here is the call graph for this function:

G4double G4INCL::ThreeVector::dot ( const ThreeVector v) const
inline

Dot product.

Definition at line 97 of file G4INCLThreeVector.hh.

97  {
98  return (x*v.x + y*v.y + z*v.z);
99  }

Here is the caller graph for this function:

std::string G4INCL::ThreeVector::dump ( ) const
inline

Definition at line 206 of file G4INCLThreeVector.hh.

206  {
207  std::stringstream ss;
208  ss <<"(vector3 " << x << " " << y << " " << z << ")";
209  return ss.str();
210  }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::getX ( ) const
inline

Definition at line 64 of file G4INCLThreeVector.hh.

64 { return x; }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::getY ( ) const
inline

Definition at line 65 of file G4INCLThreeVector.hh.

65 { return y; }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::getZ ( ) const
inline

Definition at line 66 of file G4INCLThreeVector.hh.

66 { return z; }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::mag ( ) const
inline

Get the length of the vector.

Definition at line 73 of file G4INCLThreeVector.hh.

73 { return std::sqrt(x*x + y*y + z*z); }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::mag2 ( ) const
inline

Get the square of the length.

Definition at line 78 of file G4INCLThreeVector.hh.

78 { return (x*x + y*y + z*z); }

Here is the caller graph for this function:

ThreeVector G4INCL::ThreeVector::operator* ( const G4double  C) const
inline

Definition at line 170 of file G4INCLThreeVector.hh.

170  {
171  return ThreeVector(x*C, y*C, z*C);
172  }
double C(double temp)

Here is the call graph for this function:

template<typename T >
void G4INCL::ThreeVector::operator*= ( const T &  c)
inline

Definition at line 142 of file G4INCLThreeVector.hh.

142  {
143  x *= c;
144  y *= c;
145  z *= c;
146  }

Here is the caller graph for this function:

ThreeVector G4INCL::ThreeVector::operator+ ( const ThreeVector v) const
inline

Definition at line 158 of file G4INCLThreeVector.hh.

158  {
159  return ThreeVector(x+v.x, y+v.y, z+v.z);
160  }

Here is the call graph for this function:

void G4INCL::ThreeVector::operator+= ( const ThreeVector v)
inline

Definition at line 124 of file G4INCLThreeVector.hh.

124  {
125  x += v.x;
126  y += v.y;
127  z += v.z;
128  }
ThreeVector G4INCL::ThreeVector::operator- ( ) const
inline

Unary minus operator.

Definition at line 131 of file G4INCLThreeVector.hh.

131  {
132  return ThreeVector(-x,-y,-z);
133  }

Here is the call graph for this function:

ThreeVector G4INCL::ThreeVector::operator- ( const ThreeVector v) const
inline

Definition at line 154 of file G4INCLThreeVector.hh.

154  {
155  return ThreeVector(x-v.x, y-v.y, z-v.z);
156  }

Here is the call graph for this function:

void G4INCL::ThreeVector::operator-= ( const ThreeVector v)
inline

Definition at line 135 of file G4INCLThreeVector.hh.

135  {
136  x -= v.x;
137  y -= v.y;
138  z -= v.z;
139  }
ThreeVector G4INCL::ThreeVector::operator/ ( const G4double  C) const
inline

Divides all components of the vector with a constant number.

Definition at line 165 of file G4INCLThreeVector.hh.

165  {
166  const G4double oneOverC = 1./C;
167  return ThreeVector(x*oneOverC, y*oneOverC, z*oneOverC);
168  }
double C(double temp)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

template<typename T >
void G4INCL::ThreeVector::operator/= ( const T &  c)
inline

Definition at line 149 of file G4INCLThreeVector.hh.

149  {
150  const G4double oneOverC = 1./c;
151  this->operator*=(oneOverC);
152  }
void operator*=(const T &c)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4INCL::ThreeVector::perp ( ) const
inline

Definition at line 68 of file G4INCLThreeVector.hh.

68 { return std::sqrt(x*x + y*y); }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::perp2 ( ) const
inline

Definition at line 69 of file G4INCLThreeVector.hh.

69 { return x*x + y*y; }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::phi ( ) const
inline

Phi angle

Definition at line 90 of file G4INCLThreeVector.hh.

90  {
91  return x == 0.0 && y == 0.0 ? 0.0 : std::atan2(y,x);
92  }

Here is the caller graph for this function:

std::string G4INCL::ThreeVector::print ( ) const
inline

Definition at line 200 of file G4INCLThreeVector.hh.

200  {
201  std::stringstream ss;
202  ss <<"(x = " << x << " y = " << y << " z = " << z <<")";
203  return ss.str();
204  }

Here is the caller graph for this function:

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 179 of file G4INCLThreeVector.hh.

179  {
180  // Use Rodrigues' formula
181  const G4double cos = std::cos(angle);
182  const G4double sin = std::sin(angle);
183  (*this) = (*this) * cos + axis.vector(*this) * sin + axis * (axis.dot(*this)*(1.-cos));
184  }
static G4double angle[DIM]
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4INCL::ThreeVector::set ( const G4double  ax,
const G4double  ay,
const G4double  az 
)
inline

Set all the coordinates.

Definition at line 122 of file G4INCLThreeVector.hh.

122 { x=ax; y=ay; z=az; }
void G4INCL::ThreeVector::setX ( G4double  ax)
inline

Set the x coordinate.

Definition at line 113 of file G4INCLThreeVector.hh.

113 { x = ax; }

Here is the caller graph for this function:

void G4INCL::ThreeVector::setY ( G4double  ay)
inline

Set the y coordinate.

Definition at line 116 of file G4INCLThreeVector.hh.

116 { y = ay; }

Here is the caller graph for this function:

void G4INCL::ThreeVector::setZ ( G4double  az)
inline

Set the z coordinate.

Definition at line 119 of file G4INCLThreeVector.hh.

119 { z = az; }

Here is the caller graph for this function:

G4double G4INCL::ThreeVector::theta ( ) const
inline

Theta angle

Definition at line 83 of file G4INCLThreeVector.hh.

83  {
84  return x == 0.0 && y == 0.0 && z == 0.0 ? 0.0 : std::atan2(perp(),z);
85  }
G4double perp() const

Here is the call graph for this function:

Here is the caller graph for this function:

ThreeVector G4INCL::ThreeVector::vector ( const ThreeVector v) const
inline

Vector product.

Definition at line 104 of file G4INCLThreeVector.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:


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