40 return std::atan2(
y - other.
y,
x - other.
x);
48 if (
x == 0 &&
y == 0) {
51 return std::atan2(
y,
x);
59 return std::hypotf(
x - other.
x,
y - other.
y);
67 T
dot(
const Vec2& other)
const {
return (
x * other.
x) + (
y * other.
y); }
74 T
cross(
const Vec2& other)
const {
return (
x * other.
y) - (
y * other.
x); }
88 return Vec2(
x + other.
x,
y + other.
y);
97 return Vec2(
x - other.
x,
y - other.
y);
106 return Vec2(
x * scalar,
y * scalar);
115 return Vec2(
x / scalar,
y / scalar);
168 return x == other.
x &&
y == other.
y;
177 return x != other.
x ||
y != other.
y;
192 template <
typename T>
212 T dotProduct =
dot(other);
214 return std::acos(dotProduct / magnitudes);
222 return std::sqrt((
x - other.
x) * (
x - other.
x) +
223 (
y - other.
y) * (
y - other.
y) +
224 (
z - other.
z) * (
z - other.
z));
233 return (
x * other.
x) + (
y * other.
y) + (
z * other.
z);
242 return Vec3((
y * other.
z) - (
z * other.
y), (
z * other.
x) - (
x * other.
z),
243 (
x * other.
y) - (
y * other.
x));
258 return Vec3(
x + other.
x,
y + other.
y,
z + other.
z);
267 return Vec3(
x - other.
x,
y - other.
y,
z - other.
z);
276 return Vec3(
x * scalar,
y * scalar,
z * scalar);
285 return Vec3(
x / scalar,
y / scalar,
z / scalar);
342 return x == other.
x &&
y == other.
y &&
z == other.
z;
351 return x != other.
x ||
y != other.
y ||
z != other.
z;
369 template <
typename T>
Quad operator-(const Quad< T > &quad) const
Subtract a vector from the rectangle.
bool collidesBottom(const Quad &other) const
Quad operator+(const Quad< T > &quad) const
Add a vector to the rectangle.
Quad operator/(const T scalar) const
Divide the rectangle by a scalar.
bool collidesLeft(const Quad &other) const
Vec2< T > getCenter() const
Get center of the rectangle.
Quad()
Default constructor for the Quad class.
bool collides(const Quad &other) const
Check if a rectangle is inside the rectangle.
Quad(const Vec2< T > &position, const Vec2< T > &size)
Constructor for the Quad class.
Quad(T x, T y, T width, T height)
Constructor for the Quad class.
void setSize(T width, T height)
Set the size of the rectangle.
bool collidesTop(const Quad &other) const
Vec2< T > size
The size of the rectangle.
Vec2< T > position
The position of the rectangle.
Quad operator*(const T scalar) const
Multiply the rectangle by a scalar.
void setPosition(T x, T y)
Set the position of the rectangle.
bool contains(const Vec2< T > &point) const
Check if a point is inside the rectangle.
bool collidesRight(const Quad &other) const
bool contains(T x, T y) const
Check if coordinates are inside the rectangle.
T cross(const Vec2 &other) const
Calculate the cross product of two vectors.
Vec2 operator+(const Vec2 &other) const
Addition operator for the Vec2 class.
Vec2 operator/(const T scalar) const
Division operator for the Vec2 class.
Vec2 & operator-=(const Vec2 &other)
Subtraction assignment operator for the Vec2 class.
bool operator!=(const Vec2 &other) const
Inequality operator for the Vec2 class.
T y
The y component of the vector.
T x
The x component of the vector.
Vec2 operator*(const T scalar) const
Multiplication operator for the Vec2 class.
T distance(const Vec2 &other) const
Get distance between two vectors.
Vec2 & operator/=(const T scalar)
Division assignment operator for the Vec2 class.
Vec2(T x, T y)
Constructor for the Vec2 class.
Vec2 & operator*=(const T scalar)
Multiplication assignment operator for the Vec2 class.
T angle(const Vec2 &other) const
Get angle of two vectors.
T magnitude() const
Calculate the magnitude of the vector.
Vec2 operator-(const Vec2 &other) const
Subtraction operator for the Vec2 class.
T angle() const
Calculate the angle of the vector.
Vec2()
Default constructor for the Vec2 class.
Vec2 & operator+=(const Vec2 &other)
Addition assignment operator for the Vec2 class.
T dot(const Vec2 &other) const
Calculate the dot product of two vectors.
bool operator==(const Vec2 &other) const
Equality operator for the Vec2 class.
T z
The z component of the vector.
Vec3(T x, T y, T z)
Constructor for the Vec3 class.
Vec3()
Default constructor for the Vec3 class.
Vec3 operator/(const T scalar) const
Division operator for the Vec3 class.
T x
The x component of the vector.
Vec3 cross(const Vec3 &other) const
Calculate the cross product of two vectors.
Vec3 & operator-=(const Vec3 &other)
Subtraction assignment operator for the Vec3 class.
T dot(const Vec3 &other) const
Calculate the dot product of two vectors.
Vec3 operator+(const Vec3 &other) const
Addition operator for the Vec3 class.
T magnitude() const
Calculate the magnitude of the vector.
T y
The y component of the vector.
T angle(const Vec3 &other) const
Get angle between two vectors (in 3D space).
Vec3 & operator*=(const T scalar)
Multiplication assignment operator for the Vec3 class.
Vec3 & operator/=(const T scalar)
Division assignment operator for the Vec3 class.
bool operator!=(const Vec3 &other) const
Inequality operator for the Vec3 class.
Vec3 operator-(const Vec3 &other) const
Subtraction operator for the Vec3 class.
bool operator==(const Vec3 &other) const
Equality operator for the Vec3 class.
Vec3 & operator+=(const Vec3 &other)
Addition assignment operator for the Vec3 class.
T distance(const Vec3 &other) const
Get distance between two vectors.
Vec3 operator*(const T scalar) const
Multiplication operator for the Vec3 class.