33 #define INCLXX_IN_GEANT4_MODE 1
44 #ifndef G4INCLThreeVector_hh
45 #define G4INCLThreeVector_hh 1
56 :x(0.0), y(0.0), z(0.0)
72 inline G4double mag()
const {
return std::sqrt(x*x + y*y + z*z); }
83 return x == 0.0 && y == 0.0 && z == 0.0 ? 0.0 : std::atan2(
perp(),z);
90 return x == 0.0 && y == 0.0 ? 0.0 : std::atan2(y,x);
97 return (x*v.x + y*v.y + z*v.z);
163 return ThreeVector(x*oneOverC, y*oneOverC, z*oneOverC);
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));
183 std::stringstream ss;
184 ss <<
"(x = " << x <<
" y = " << y <<
" z = " << z <<
")";
189 std::stringstream ss;
190 ss <<
"(vector3 " << x <<
" " << y <<
" " << z <<
")";
G4double dot(const ThreeVector &v) const
void rotate(const G4double angle, const ThreeVector &axis)
Rotate the vector by a given angle around a given axis.
ThreeVector operator*(const G4double C) const
ThreeVector operator+(const ThreeVector &v) const
ThreeVector vector(const ThreeVector &v) const
void setY(G4double ay)
Set the y coordinate.
void operator*=(const T &c)
void operator+=(const ThreeVector &v)
ThreeVector operator/(const G4double C) const
void operator-=(const ThreeVector &v)
ThreeVector(G4double ax, G4double ay, G4double az)
ThreeVector operator-() const
Unary minus operator.
std::string print() const
void setX(G4double ax)
Set the x coordinate.
void operator/=(const T &c)
void setZ(G4double az)
Set the z coordinate.