38 #ifndef INCLUDE_SVECTOR_EMBED_HPP_
39 #define INCLUDE_SVECTOR_EMBED_HPP_
64 EmbVec2D(
const float xOther,
const float yOther) :
x{xOther},
y{yOther} {}
183 EmbVec3D(
const float xOther,
const float yOther,
const float zOther)
184 :
x{xOther},
y{yOther},
z{zOther} {}
203 if (
this == &other) {
303 inline void x(
EmbVec2D &v,
const float xValue) { v.
x = xValue; }
320 inline void x(
EmbVec3D &v,
const float xValue) { v.
x = xValue; }
337 inline void y(
EmbVec2D &v,
const float yValue) { v.
y = yValue; }
354 inline void y(
EmbVec3D &v,
const float yValue) { v.
y = yValue; }
371 inline void z(
EmbVec3D &v,
const float zValue) { v.
z = zValue; }
471 return lhs.
x == rhs.
x && lhs.
y == rhs.
y;
483 return !(lhs == rhs);
495 return lhs.
x * rhs.
x + lhs.
y * rhs.
y;
506 return sqrtf(vec.
x * vec.
x + vec.
y * vec.
y);
561 const auto xPrime = vec.
x * cosf(ang) - vec.
y * sinf(ang);
562 const auto yPrime = vec.
x * sinf(ang) + vec.
y * cosf(ang);
638 return EmbVec3D{lhs.
x * rhs, lhs.
y * rhs, lhs.
z * rhs};
653 return EmbVec3D{lhs.
x / rhs, lhs.
y / rhs, lhs.
z / rhs};
665 return lhs.
x == rhs.
x && lhs.
y == rhs.
y && lhs.
z == rhs.
z;
677 return !(lhs == rhs);
689 return lhs.
x * rhs.
x + lhs.
y * rhs.
y + lhs.
z * rhs.
z;
701 const float newx = lhs.
y * rhs.
z - lhs.
z * rhs.
y;
702 const float newy = lhs.
z * rhs.
x - lhs.
x * rhs.
z;
703 const float newz = lhs.
x * rhs.
y - lhs.
y * rhs.
x;
716 return sqrtf(vec.
x * vec.
x + vec.
y * vec.
y + vec.
z * vec.
z);
801 const auto xPrime = vec.
x;
802 const auto yPrime = vec.
y * cosf(ang) - vec.
z * sinf(ang);
803 const auto zPrime = vec.
y * sinf(ang) + vec.
z * cosf(ang);
805 return EmbVec3D{xPrime, yPrime, zPrime};
827 const auto xPrime = vec.
x * cosf(ang) + vec.
z * sinf(ang);
828 const auto yPrime = vec.
y;
829 const auto zPrime = -vec.
x * sinf(ang) + vec.
z * cosf(ang);
831 return EmbVec3D{xPrime, yPrime, zPrime};
853 const auto xPrime = vec.
x * cosf(ang) - vec.
y * sinf(ang);
854 const auto yPrime = vec.
x * sinf(ang) + vec.
y * cosf(ang);
855 const auto zPrime = vec.
z;
857 return EmbVec3D{xPrime, yPrime, zPrime};
double x(const Vector2D &v)
Gets the x-component of a 2D vector.
Definition: simplevectors.hpp:1187
double alpha(const Vector3D &v)
Gets α angle.
Definition: simplevectors.hpp:1406
Vector3D cross(const Vector3D &lhs, const Vector3D &rhs)
Cross product of two vectors.
Definition: simplevectors.hpp:1386
Vector< D, T > operator+(const Vector< D, T > &lhs, const Vector< D, T > &rhs)
Vector addition.
Definition: simplevectors.hpp:1535
double angle(const Vector2D &v)
Gets the angle of a 2D vector in radians.
Definition: simplevectors.hpp:1350
Vector3D rotateAlpha(const Vector3D &v, const double &ang)
Rotates around x-axis.
Definition: simplevectors.hpp:1446
Vector3D rotateGamma(const Vector3D &v, const double &ang)
Rotates around z-axis.
Definition: simplevectors.hpp:1498
T magn(const Vector< D, T > &v)
Gets the magnitude of the vector.
Definition: simplevectors.hpp:1299
T dot(const Vector< D, T > &lhs, const Vector< D, T > &rhs)
Calculates the dot product of two vectors.
Definition: simplevectors.hpp:1279
Vector2D rotate(const Vector2D &v, const double ang)
Rotates a 2D vector by a certain angle.
Definition: simplevectors.hpp:1364
double beta(const Vector3D &v)
Gets β angle.
Definition: simplevectors.hpp:1420
double y(const Vector2D &v)
Gets the y-component of a 2D vector.
Definition: simplevectors.hpp:1221
Vector3D rotateBeta(const Vector3D &v, const double &ang)
Rotates around y-axis.
Definition: simplevectors.hpp:1472
double z(const Vector3D &v)
Gets the z-component of a 3D vector.
Definition: simplevectors.hpp:1255
Vector< D, T > normalize(const Vector< D, T > &v)
Normalizes a vector.
Definition: simplevectors.hpp:1325
Vector< D, T > operator/(const Vector< D, T > &lhs, const T2 rhs)
Scalar division.
Definition: simplevectors.hpp:1622
double gamma(const Vector3D &v)
Gets γ angle.
Definition: simplevectors.hpp:1434
bool isZero(const Vector< D, T > &v)
Determines whether a vector is a zero vector.
Definition: simplevectors.hpp:1337
Vector< D, T > operator-(const Vector< D, T > &lhs, const Vector< D, T > &rhs)
Vector subtraction.
Definition: simplevectors.hpp:1565
A minimal 2D vector representation.
Definition: sv_embed.hpp:50
EmbVec2D & operator*=(const float &other)
In-place scalar multiplication.
Definition: sv_embed.hpp:139
float y
The y-component of the 2D vector.
Definition: sv_embed.hpp:159
EmbVec2D(const EmbVec2D &other)=default
Copy constructor.
EmbVec2D(EmbVec2D &&) noexcept=default
Move constructor.
EmbVec2D & operator-=(const EmbVec2D &other)
In-place subtraction.
Definition: sv_embed.hpp:126
EmbVec2D & operator=(EmbVec2D &&) noexcept=default
Move assignment operator.
float x
The x-component of the 2D vector.
Definition: sv_embed.hpp:158
EmbVec2D()
No-argument constructor.
Definition: sv_embed.hpp:56
EmbVec2D(const float xOther, const float yOther)
Initializes a vector given xy components.
Definition: sv_embed.hpp:64
EmbVec2D & operator/=(const float &other)
In-place scalar division.
Definition: sv_embed.hpp:152
A minimal 3D vector representation.
Definition: sv_embed.hpp:168
EmbVec3D(EmbVec3D &&) noexcept=default
Move constructor.
EmbVec3D(const float xOther, const float yOther, const float zOther)
Initializes a vector given xyz components.
Definition: sv_embed.hpp:183
EmbVec3D & operator-=(const EmbVec3D &other)
In-place subtraction.
Definition: sv_embed.hpp:248
EmbVec3D()
No-argument constructor.
Definition: sv_embed.hpp:174
float x
The x-component of the 3D vector.
Definition: sv_embed.hpp:283
EmbVec3D(const EmbVec3D &other)=default
Copy constructor.
float z
The z-component of the 3D vector.
Definition: sv_embed.hpp:285
EmbVec3D & operator*=(const float &other)
In-place scalar multiplication.
Definition: sv_embed.hpp:262
float y
The y-component of the 3D vector.
Definition: sv_embed.hpp:284
EmbVec3D & operator=(EmbVec3D &&) noexcept=default
Move assignment operator.
EmbVec3D & operator/=(const float &other)
In-place scalar division.
Definition: sv_embed.hpp:276