19#ifndef BDSTHREEVECTOR_H
20#define BDSTHREEVECTOR_H
21#include "BDSException.hh"
58 for (G4int i : {0, 1, 2})
67 for (G4int i : {0, 1, 2})
77 {
throw BDSException(
"BDSThreeVector::operator[]> index outside array");}
85 {
throw BDSException(
"BDSThreeVector::operator[]> index outside array");}
90 inline const T&
x()
const {
return values[0];}
91 inline const T&
y()
const {
return values[1];}
92 inline const T&
z()
const {
return values[2];}
97 {out <<
"(" << v.
values[0] <<
", " << v.
values[1] <<
", " << v.
values[2] <<
")";
return out;}
100 {
return x()*b.
x() +
y()*b.
y() +
z()*b.
z();}
General exception with possible name of object and message.
Simple three vector that's templated so the right type can be used.
BDSThreeVector()
Default constructor.
BDSThreeVector(const BDSThreeVector &other)
Copy constructor.
BDSThreeVector & operator=(const BDSThreeVector &rhs)
Assignment operator.
T values[3]
Member data - x,y,z.
T & operator[](const G4int index)
Access / set a single element.
friend BDSThreeVector operator*(const BDSThreeVector &a, const double &b)
Multiplication.
T mag() const
Get the magnitude of it.
friend std::ostream & operator<<(std::ostream &out, BDSThreeVector const &v)
Output stream.
const T & z() const
Accessor by name.
const T & x() const
Accessor by name.
friend BDSThreeVector operator+(const BDSThreeVector &a, const G4double &b)
Addition, subtraction.
const T & y() const
Accessor by name.
const T & operator[](const G4int index) const
Access a single element.
BDSThreeVector(T xIn, T yIn, T zIn)
Alternate constructor.
friend BDSThreeVector operator-(const BDSThreeVector &a, const G4double &b)
Addition, subtraction.