38 return x() == 0.0 &&
y() == 0.0 ? 0.0 : std::atan2(-
y(),
x());
44 return x() == 0.0 &&
y() == 0.0 &&
z() == 0.0 ? 0.0 : std::atan2(
magxy(),
z());
50 return mag() == 0 ? 1 :
z() /
mag();
81 throw std::runtime_error(
"Cannot normalize zero vector");
89 throw std::runtime_error(
"Cannot normalize zero vector");
101 double ptot =
mag() * v.
mag();
103 cosa =
dot(v) / ptot;
109 return std::acos(cosa);
std::complex< double > complex_t
Declares and partly implements template class BasicVector3D.
double mag2() const
Returns magnitude squared of the vector.
BasicVector3D< T > conj() const
Returns complex conjugate vector.
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
double sin2Theta() const
Returns squared sine of polar angle.
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.
double magxy2() const
Returns squared distance from z axis.
double mag() const
Returns magnitude of the vector.
double theta() const
Returns polar angle.
BasicVector3D< complex_t > complex() const
Returns this, trivially converted to complex type.
BasicVector3D< double > real() const
Returns real parts.
T z() const
Returns z-component in cartesian coordinate system.
T y() const
Returns y-component in cartesian coordinate system.
double phi() const
Returns azimuth angle.
T x() const
Returns x-component in cartesian coordinate system.
double magxy() const
Returns distance from z axis.
double angle(const BasicVector3D< T > &v) const
Returns angle with respect to another vector.
double cosTheta() const
Returns cosine of polar angle.