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};
bool operator==(const EmbVec2D &lhs, const EmbVec2D &rhs)
Compares equality of two vectors.
Definition: embed.h:470
float magn(const EmbVec2D &vec)
Gets the magnitude of the vector.
Definition: embed.h:505
EmbVec2D operator-(const EmbVec2D &lhs, const EmbVec2D &rhs)
Vector subtraction.
Definition: embed.h:399
float alpha(const EmbVec3D &vec)
Gets α angle.
Definition: embed.h:752
EmbVec3D rotateGamma(const EmbVec3D &vec, const float ang)
Rotates around z-axis.
Definition: embed.h:844
EmbVec3D rotateAlpha(const EmbVec3D &vec, const float ang)
Rotates around x-axis.
Definition: embed.h:792
float z(const EmbVec3D &v)
Gets the z-component of a 3D vector.
Definition: embed.h:363
float x(const EmbVec2D &v)
Gets the x-component of a 2D vector.
Definition: embed.h:295
float y(const EmbVec2D &v)
Gets the y-component of a 2D vector.
Definition: embed.h:329
EmbVec2D normalize(const EmbVec2D &vec)
Normalizes a vector.
Definition: embed.h:532
EmbVec3D rotateBeta(const EmbVec3D &vec, const float ang)
Rotates around y-axis.
Definition: embed.h:818
bool operator!=(const EmbVec2D &lhs, const EmbVec2D &rhs)
Compares inequality of two vectors.
Definition: embed.h:482
float beta(const EmbVec3D &vec)
Gets β angle.
Definition: embed.h:766
float dot(const EmbVec2D &lhs, const EmbVec2D &rhs)
Calculates the dot product of two vectors.
Definition: embed.h:494
EmbVec2D operator+(const EmbVec2D &lhs, const EmbVec2D &rhs)
Vector addition.
Definition: embed.h:384
bool isZero(const EmbVec2D &vec)
Determines whether a vector is a zero vector.
Definition: embed.h:539
float gamma(const EmbVec3D &vec)
Gets γ angle.
Definition: embed.h:780
EmbVec2D operator/(const EmbVec2D &lhs, const float rhs)
Scalar division.
Definition: embed.h:458
EmbVec2D operator*(const EmbVec2D &lhs, const float rhs)
Scalar multiplication.
Definition: embed.h:443
EmbVec3D cross(const EmbVec3D &lhs, const EmbVec3D &rhs)
Cross product of two vectors.
Definition: embed.h:700
EmbVec2D rotate(const EmbVec2D &vec, const float ang)
Rotates vector by a certain angle.
Definition: embed.h:553
float angle(const EmbVec2D &vec)
Gets the angle of a 2D vector in radians.
Definition: embed.h:518
A minimal 2D vector representation.
Definition: embed.h:50
EmbVec2D & operator*=(const float &other)
In-place scalar multiplication.
Definition: embed.h:139
float y
The y-component of the 2D vector.
Definition: embed.h:159
EmbVec2D(const EmbVec2D &other)=default
Copy constructor.
EmbVec2D(EmbVec2D &&) noexcept=default
Move constructor.
EmbVec2D & operator-=(const EmbVec2D &other)
In-place subtraction.
Definition: embed.h:126
EmbVec2D & operator=(EmbVec2D &&) noexcept=default
Move assignment operator.
float x
The x-component of the 2D vector.
Definition: embed.h:158
EmbVec2D()
No-argument constructor.
Definition: embed.h:56
EmbVec2D(const float xOther, const float yOther)
Initializes a vector given xy components.
Definition: embed.h:64
EmbVec2D & operator/=(const float &other)
In-place scalar division.
Definition: embed.h:152
A minimal 3D vector representation.
Definition: embed.h:168
EmbVec3D(EmbVec3D &&) noexcept=default
Move constructor.
EmbVec3D(const float xOther, const float yOther, const float zOther)
Initializes a vector given xyz components.
Definition: embed.h:183
EmbVec3D & operator-=(const EmbVec3D &other)
In-place subtraction.
Definition: embed.h:248
EmbVec3D()
No-argument constructor.
Definition: embed.h:174
float x
The x-component of the 3D vector.
Definition: embed.h:283
EmbVec3D(const EmbVec3D &other)=default
Copy constructor.
float z
The z-component of the 3D vector.
Definition: embed.h:285
EmbVec3D & operator*=(const float &other)
In-place scalar multiplication.
Definition: embed.h:262
float y
The y-component of the 3D vector.
Definition: embed.h:284
EmbVec3D & operator=(EmbVec3D &&) noexcept=default
Move assignment operator.
EmbVec3D & operator/=(const float &other)
In-place scalar division.
Definition: embed.h:276