10 #ifndef INCLUDE_SVECTOR_VECTOR3D_HPP_
11 #define INCLUDE_SVECTOR_VECTOR3D_HPP_
114 const double newx = this->
y() * other.
z() - this->
z() * other.
y();
115 const double newy = this->
z() * other.
x() - this->
x() * other.
z();
116 const double newz = this->
x() * other.
y() - this->
y() * other.
x();
134 return T{this->
x(), this->
y(), this->
z()};
150 return T{this->getAlpha(), this->getBeta(), this->getGamma()};
168 template <AngleDir D>
double angle()
const {
171 return this->getAlpha();
173 return this->getBeta();
175 return this->getGamma();
199 return this->rotateAlpha(ang);
201 return this->rotateBeta(ang);
203 return this->rotateGamma(ang);
215 double getAlpha()
const {
return std::acos(this->
x() / this->
magn()); }
224 double getBeta()
const {
return std::acos(this->
y() / this->
magn()); }
233 double getGamma()
const {
return std::acos(this->
z() / this->
magn()); }
238 Vector3D rotateAlpha(
const double &ang)
const {
247 const double xPrime = this->
x();
248 const double yPrime = this->
y() * std::cos(ang) - this->
z() * std::sin(ang);
249 const double zPrime = this->
y() * std::sin(ang) + this->
z() * std::cos(ang);
251 return Vector3D{xPrime, yPrime, zPrime};
257 Vector3D rotateBeta(
const double &ang)
const {
266 const double xPrime = this->
x() * std::cos(ang) + this->
z() * std::sin(ang);
267 const double yPrime = this->
y();
268 const double zPrime =
269 -this->
x() * std::sin(ang) + this->
z() * std::cos(ang);
271 return Vector3D{xPrime, yPrime, zPrime};
277 Vector3D rotateGamma(
const double &ang)
const {
286 const double xPrime = this->
x() * std::cos(ang) - this->
y() * std::sin(ang);
287 const double yPrime = this->
x() * std::sin(ang) + this->
y() * std::cos(ang);
288 const double zPrime = this->
z();
290 return Vector3D{xPrime, yPrime, zPrime};
@ ALPHA
Angle between positive x-axis and vector.
Definition: units.hpp:24
@ BETA
Angle between positive y-axis and vector.
Definition: units.hpp:25
Contains a base vector representation.
A base vector representation.
Definition: vector.hpp:34
Vector()
No-argument constructor.
Definition: vector.hpp:67
T magn() const
Magnitude.
Definition: vector.hpp:426
std::array< T, D > m_components
An array of components for the vector.
Definition: vector.hpp:630
A simple 3D vector representation.
Definition: vector3d.hpp:26
T anglesAs() const
Converts angles to another object.
Definition: vector3d.hpp:149
Vector3D(const double x, const double y, const double z)
Initializes a vector given xyz components.
Definition: vector3d.hpp:37
Vector3D rotate(const double &ang) const
Rotates vector around a certain axis by a certain angle.
Definition: vector3d.hpp:196
Vector3D(const Vec3_ &other)
Copy constructor for the base class.
Definition: vector3d.hpp:46
void z(const double &newZ)
Sets z-component.
Definition: vector3d.hpp:104
Vector3D cross(const Vector3D &other) const
Cross product of two vectors.
Definition: vector3d.hpp:113
T componentsAs() const
Converts vector to another object.
Definition: vector3d.hpp:133
double z() const
Gets z-component.
Definition: vector3d.hpp:95
void y(const double &newY)
Sets y-component.
Definition: vector3d.hpp:86
double angle() const
Gets a specific angle of the vector.
Definition: vector3d.hpp:168
void x(const double &newX)
Sets x-component.
Definition: vector3d.hpp:68
double x() const
Gets x-component.
Definition: vector3d.hpp:59
double y() const
Gets y-component.
Definition: vector3d.hpp:77