4#ifndef LODESTONE_VEC3I_H
5#define LODESTONE_VEC3I_H
11 static_assert(std::is_arithmetic_v<T>,
"T must be a numeric type");
18 explicit constexpr Vec3(
const Vec3<O>& rhs) :
x(static_cast<T>(rhs.
x)),
y(static_cast<T>(rhs.
y)),
z(static_cast<T>(rhs.
z)) {
22 return std::format(
"Vec3[x={}, y={}, z={}]",
x,
y,
z);
25 constexpr operator T *() {
return &
x; }
26 constexpr operator const T *()
const {
return &
x; }
29 return x == rhs.
x &&
y == rhs.
y &&
z == rhs.
z;
33 return {
x + v,
y + v,
z + v};
37 return {
x - v,
y - v,
z - v};
41 return {
x * v,
y * v,
z * v};
45 return {
x / v,
y / v,
z / v};
81 return {
x + rhs.
x,
y + rhs.
y,
z + rhs.
z};
85 return {
x - rhs.
x,
x - rhs.
y,
z - rhs.
z};
89 return {
x * rhs.
x,
y * rhs.
y,
z * rhs.
z};
93 return {
x / rhs.
x,
y / rhs.
y,
z / rhs.
z};
129 float m = std::sqrt(this->x * this->x + this->y * this-> y + this->z * this->z);
139 float m = std::sqrt(this->x * this->x + this->y * this-> y + this->z * this->z);
149 this->x = oy * rhs.
z - oz * rhs.
y;
150 this->y = oz * rhs.
x - ox * rhs.
z;
151 this->z = ox * rhs.
y - oy * rhs.
x;
162 oy * rhs.
z - oz * rhs.
y,
163 oz * rhs.
x - ox * rhs.
z,
164 ox * rhs.
y - oy * rhs.
x
169 template <
typename T>
172 template <
typename T>
180template <
typename T>
struct std::hash<
lodestone::level::types::Vec3<T>> {
183 return std::hash<T>()(v.x) ^ (std::hash<T>()(v.y) << 1) ^
184 (std::hash<T>()(v.z) << 2);
189struct std::formatter<
lodestone::level::types::Vec3<T>> {
190 template <
typename FormatParseContext>
constexpr auto parse(FormatParseContext &pc) {
return pc.begin(); }
constexpr Vec3< T > VEC3_ONE
Definition Vec3.h:173
Vec3< double > Vec3d
Definition Vec3.h:177
Vec3< int > Vec3i
Definition Vec3.h:175
Vec3< float > Vec3f
Definition Vec3.h:176
constexpr Vec3< T > VEC3_ZERO
Definition Vec3.h:170
constexpr Vec3 & operator/=(const T v)
Definition Vec3.h:72
std::string toString() const
Definition Vec3.h:21
constexpr Vec3 crossed(const Vec3 &rhs) const
Definition Vec3.h:156
constexpr bool operator==(const Vec3 &rhs) const
Definition Vec3.h:28
constexpr Vec3 operator+(const T v) const
Definition Vec3.h:32
constexpr Vec3 operator/(const Vec3 &rhs) const
Definition Vec3.h:92
constexpr Vec3 & operator-=(const Vec3 &rhs)
Definition Vec3.h:104
constexpr Vec3 operator*(const Vec3 &rhs) const
Definition Vec3.h:88
constexpr Vec3 operator*(const T v) const
Definition Vec3.h:40
constexpr Vec3 & operator+=(const Vec3 &rhs)
Definition Vec3.h:96
constexpr Vec3(const T x, const T y, const T z)
Definition Vec3.h:15
constexpr Vec3 operator-(const Vec3 &rhs) const
Definition Vec3.h:84
int z
Definition Vec3.h:13
int x
Definition Vec3.h:13
constexpr Vec3 & operator*=(const Vec3 &rhs)
Definition Vec3.h:112
constexpr Vec3 operator/(const T v) const
Definition Vec3.h:44
constexpr Vec3 operator-(const T v) const
Definition Vec3.h:36
constexpr Vec3 operator+(const Vec3 &rhs) const
Definition Vec3.h:80
constexpr Vec3 & normalize()
Definition Vec3.h:128
constexpr Vec3 & operator+=(const T v)
Definition Vec3.h:48
constexpr Vec3 & operator*=(const T v)
Definition Vec3.h:64
int y
Definition Vec3.h:13
constexpr Vec3 normalized() const
Definition Vec3.h:138
constexpr Vec3 & operator-=(const T v)
Definition Vec3.h:56
constexpr Vec3 & cross(const Vec3 &rhs)
Definition Vec3.h:144
constexpr Vec3(const Vec3< O > &rhs)
Definition Vec3.h:18
constexpr Vec3 & operator/=(const Vec3 &rhs)
Definition Vec3.h:120
size_t operator()(const lodestone::level::types::Vec3< T > &v) const noexcept
Definition Vec3.h:182