15 constexpr Vec3() :
x(0.0f),
y(0.0f),
z(0.0f) {}
16 constexpr Vec3(
float _x,
float _y,
float _z) :
x(_x),
y(_y),
z(_z) {}
21 return Vec3(
x + other.x,
y + other.y,
z + other.z);
24 return Vec3(
x - other.x,
y - other.y,
z - other.z);
39 return Vec3(
x * scalar,
y * scalar,
z * scalar);
42 return Vec3(
x / scalar,
y / scalar,
z / scalar);
54 return Vec3(0.0f, 0.0f, 0.0f);
55 return Vec3(
x / len,
y / len,
z / len);
58 Vec3 diff = *
this - other;
62 Vec3 diff = *
this - other;
68 [[nodiscard]]
constexpr float dot(
const Vec3& other)
const noexcept {
69 return x * other.x +
y * other.y +
z * other.z;
73 y * other.z -
z * other.y,
z * other.x -
x * other.z,
x * other.y -
y * other.x);
78 void print()
const { std::cout <<
"Vec3(" <<
x <<
", " <<
y <<
", " <<
z <<
")\n"; }
81 os <<
"Vec3(" << vec.
x <<
", " << vec.
y <<
", " << vec.
z <<
")";
A 3-component vector structure (x, y, z) with standard math operations.
Definition MathUtils.h:11
constexpr Vec3 & operator+=(const Vec3 &other) noexcept
Definition MathUtils.h:26
float DistanceFromPoint(const Core::Vec3 &other) const
Definition MathUtils.h:61
constexpr Vec3 & operator-=(const Vec3 &other) noexcept
Definition MathUtils.h:32
float x
Definition MathUtils.h:12
float squaredLength() const
Definition MathUtils.h:47
constexpr Vec3 operator*(float scalar) const noexcept
Definition MathUtils.h:38
constexpr float dot(const Vec3 &other) const noexcept
Definition MathUtils.h:68
float z
Definition MathUtils.h:12
constexpr Vec3 operator-(const Vec3 &other) const noexcept
Definition MathUtils.h:23
float SquaredDistanceFromPoint(const Core::Vec3 &other) const
Definition MathUtils.h:57
constexpr Vec3 operator/(float scalar) const noexcept
Definition MathUtils.h:41
constexpr Vec3 cross(const Vec3 &other) const noexcept
Definition MathUtils.h:71
Vec3 normalize() const
Definition MathUtils.h:51
constexpr Vec3()
Definition MathUtils.h:15
constexpr Vec3 operator+(const Vec3 &other) const noexcept
Definition MathUtils.h:20
float y
Definition MathUtils.h:12
float length() const
Definition MathUtils.h:49
friend std::ostream & operator<<(std::ostream &os, const Vec3 &vec)
Definition MathUtils.h:80
void print() const
Definition MathUtils.h:78
constexpr Vec3(float _x, float _y, float _z)
Definition MathUtils.h:16