15 #ifndef BORNAGAIN_BASE_VECTOR_BASICVECTOR3D_H
16 #define BORNAGAIN_BASE_VECTOR_BASICVECTOR3D_H
64 T
x()
const {
return v_[0]; }
66 T
y()
const {
return v_[1]; }
68 T
z()
const {
return v_[2]; }
71 void setX(
const T& a) { v_[0] = a; }
73 void setY(
const T& a) { v_[1] = a; }
75 void setZ(
const T& a) { v_[2] = a; }
129 double mag2()
const {
return std::norm(v_[0]) + std::norm(v_[1]) + std::norm(v_[2]); }
135 double magxy2()
const {
return std::norm(v_[0]) + std::norm(v_[1]); }
209 return os <<
"(" << a.
x() <<
"," << a.
y() <<
"," << a.
z() <<
")";
284 return (a.
x() == b.
x() && a.
y() == b.
y() && a.
z() == b.
z());
291 return (a.
x() != b.
x() || a.
y() != b.
y() || a.
z() != b.
z());
313 return left_star.
x() * v.
x() + left_star.
y() * v.
y() + left_star.
z() * v.
z();
324 y() * v.
z() - v.
y() * z(), z() * v.
x() - v.
z() * x(), x() * v.
y() - v.
x() * y());
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
Forked from CLHEP/Geometry by E.
auto operator*=(U a)
Multiplies this with a scalar, and returns result.
double mag2() const
Returns magnitude squared of the vector.
bool operator!=(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Comparison of two vectors for inequality.
BasicVector3D< T > conj() const
Returns complex conjugate vector.
BasicVector3D(const T x1, const T y1, const T z1)
Constructor from cartesian components.
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 > rotated(double a, const BasicVector3D< T > &v) const
Returns result of rotation around the axis specified by another vector.
BasicVector3D< T > rotatedY(double a) const
Returns result of rotation around y-axis.
BasicVector3D< T > project(const BasicVector3D< T > &v) const
Returns projection of this onto other vector: (this*v)*v/|v|^2.
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.
double magxy2() const
Returns squared distance from z axis.
BasicVector3D< T > operator+(const BasicVector3D< T > &v)
Unary plus.
auto operator*(const BasicVector3D< T > &v, const U a)
Multiplication vector by scalar.
double mag() const
Returns magnitude of the vector.
double theta() const
Returns polar angle.
BasicVector3D()
Default constructor.
BasicVector3D< double > real() const
Returns real parts.
void setX(const T &a)
Sets x-component in cartesian coordinate system.
auto operator*(const U a, const BasicVector3D< T > &v)
Multiplication scalar by vector.
BasicVector3D< T > rotatedZ(double a) const
Returns result of rotation around z-axis.
T z() const
Returns z-component in cartesian coordinate system.
BasicVector3D< T > & operator+=(const BasicVector3D< T > &v)
Adds other vector to this, and returns result.
BasicVector3D< T > operator/(const BasicVector3D< T > &v, U a)
Division vector by scalar.
void setY(const T &a)
Sets y-component in cartesian coordinate system.
BasicVector3D< T > rotatedX(double a) const
Returns result of rotation around x-axis.
BasicVector3D< T > & operator-=(const BasicVector3D< T > &v)
Subtracts other vector from this, and returns result.
T operator[](int i) const
Returns components by index.
T & operator[](int i)
Sets components by index.
T y() const
Returns y-component in cartesian coordinate system.
BasicVector3D< T > operator-(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Subtraction of two vectors.
bool operator==(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Comparison of two vectors for equality.
auto operator/=(U a)
Divides this by a scalar, and returns result.
double phi() const
Returns azimuth angle.
std::ostream & operator<<(std::ostream &os, const BasicVector3D< T > &a)
Output to stream.
T x() const
Returns x-component in cartesian coordinate system.
void setZ(const T &a)
Sets z-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.
auto cross(const BasicVector3D< U > &v) const
Returns cross product of vectors (linear in both arguments).
BasicVector3D< std::complex< double > > complex() const
Returns this, trivially converted to complex type.
BasicVector3D< T > operator+(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Addition of two vectors.
double cosTheta() const
Returns cosine of polar angle.
BasicVector3D< T > operator-(const BasicVector3D< T > &v)
Unary minus.