31 F3D_FUNC
explicit f3d() noexcept : x(0), y(0), z(0) {}
32 F3D_FUNC
explicit f3d(VIPRA::f_pnt valX) noexcept : x(valX), y(0), z(0) {}
33 F3D_FUNC
explicit f3d(VIPRA::f_pnt valX, VIPRA::f_pnt valY) noexcept
34 : x(valX), y(valY), z(0)
37 F3D_FUNC
explicit f3d(VIPRA::f_pnt valX, VIPRA::f_pnt valY, VIPRA::f_pnt valZ) noexcept
38 : x(valX), y(valY), z(valZ)
41 F3D_FUNC f3d(f3d
const& other)
noexcept =
default;
42 F3D_FUNC f3d(f3d&& other)
noexcept =
default;
43 F3D_FUNC_W_DISCARD
auto operator=(f3d
const& other)
noexcept -> f3d& =
default;
44 F3D_FUNC_W_DISCARD
auto operator=(f3d&& other)
noexcept -> f3d& =
default;
46 [[nodiscard]] __attribute__((always_inline))
static auto random(
49 std::uniform_real_distribution<VIPRA::f_pnt> dist{-1.0, 1.0};
51 return retVal.
unit() * magnitude;
54 template <F3D_IDX
idx_t>
55 F3D_FUNC
auto operator[](idx_t index) -> VIPRA::f_pnt&
71 throw std::out_of_range(
"Attempt to access invalid index on VIPRA::f3d");
75 template <F3D_IDX
idx_t>
76 F3D_FUNC
auto operator[](idx_t index)
const -> VIPRA::f_pnt
92 throw std::out_of_range(
"Attempt to access invalid index on VIPRA::f3d");
96 template <Concepts::Numeric data_t>
97 F3D_FUNC
auto operator*(data_t&& multiplier)
const noexcept -> f3d
99 return f3d{x, y, z} *= std::forward<data_t>(multiplier);
101 template <Concepts::Numeric data_t>
102 F3D_FUNC_W_DISCARD
auto operator*=(data_t&& multiplier)
noexcept -> f3d&
110 template <Concepts::Numeric data_t>
111 F3D_FUNC
auto operator/(data_t&& divisor)
const noexcept -> f3d
113 assert(divisor != 0);
115 return f3d{x, y, z} /= std::forward<data_t>(divisor);
117 template <Concepts::Numeric data_t>
118 F3D_FUNC_W_DISCARD
auto operator/=(data_t&& divisor)
noexcept -> f3d&
120 assert(divisor != 0);
128 F3D_FUNC
auto operator-(f3d
const& other)
const noexcept -> f3d
130 return f3d{x - other.x, y - other.y, z - other.z};
132 F3D_FUNC
auto operator-(f3d&& other)
const noexcept -> f3d
134 return f3d{x - other.x, y - other.y, z - other.z};
136 F3D_FUNC
auto operator+(f3d
const& other)
const noexcept -> f3d
138 return f3d{x + other.x, y + other.y, z + other.z};
140 F3D_FUNC
auto operator+(f3d&& other)
const noexcept -> f3d
142 return f3d{x + other.x, y + other.y, z + other.z};
145 F3D_FUNC_W_DISCARD
auto operator+=(f3d
const& other)
noexcept -> f3d&
152 F3D_FUNC_W_DISCARD
auto operator+=(f3d&& other)
noexcept -> f3d&
160 F3D_FUNC_W_DISCARD
auto operator-=(f3d
const& other)
noexcept -> f3d&
167 F3D_FUNC_W_DISCARD
auto operator-=(f3d&& other)
noexcept -> f3d&
175 F3D_FUNC
auto distance_to_sqrd(f3d
const& other)
const noexcept -> VIPRA::f_pnt
177 const VIPRA::f_pnt deltaX = other.x - x;
178 const VIPRA::f_pnt deltaY = other.y - y;
179 const VIPRA::f_pnt deltaZ = other.z - z;
181 return (deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ);
184 F3D_FUNC
auto distance_to(f3d
const& other)
const -> VIPRA::f_pnt
186 const VIPRA::f_pnt deltaX = other.x - x;
187 const VIPRA::f_pnt deltaY = other.y - y;
188 const VIPRA::f_pnt deltaZ = other.z - z;
190 return std::sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
193 F3D_FUNC
auto distance_to(f3d&& other)
const -> VIPRA::f_pnt
195 const VIPRA::f_pnt deltaX = other.x - x;
196 const VIPRA::f_pnt deltaY = other.y - y;
197 const VIPRA::f_pnt deltaZ = other.z - z;
199 return std::sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
202 F3D_FUNC
auto operator==(f3d
const& other)
const noexcept ->
bool
204 return (x == other.x && y == other.y && z == other.z);
206 F3D_FUNC
auto operator==(f3d&& other)
const noexcept ->
bool
208 return (x == other.x && y == other.y && z == other.z);
211 F3D_FUNC
auto operator!=(f3d
const& other)
const noexcept ->
bool
213 return (x != other.x || y != other.y || z != other.z);
215 F3D_FUNC
auto operator!=(f3d&& other)
const noexcept ->
bool
217 return (x != other.x || y != other.y || z != other.z);
220 F3D_FUNC
auto operator-()
const noexcept -> f3d {
return f3d{-x, -y, -z}; }
227 F3D_FUNC
auto unit() const noexcept -> f3d
229 if ( x == 0 && y == 0 && z == 0 ) {
232 return f3d{x, y, z} /
mag();
240 F3D_FUNC
auto mag_sqrd() const noexcept -> VIPRA::f_pnt
242 return (x * x) + (y * y) + (z * z);
250 F3D_FUNC
auto mag() const noexcept -> VIPRA::f_pnt
252 return std::sqrt((x * x) + (y * y) + (z * z));
261 F3D_FUNC
auto dot(f3d
const& other)
const noexcept -> VIPRA::f_pnt
263 return (x * other.x) + (y * other.y) + (z * other.z);
272 F3D_FUNC
auto cross(f3d
const& other)
const noexcept -> f3d
274 return f3d{(y * other.z) - (z * other.y), (z * other.x) - (x * other.z),
275 (x * other.y) - (y * other.x)};
283 [[nodiscard]] VIPRA_INLINE
auto to_string() const -> std::
string
285 return std::string{
"("} + std::to_string(x) +
", " + std::to_string(y) +
", " +
286 std::to_string(z) +
")";