11#include <mv/math/detail/VectorOps.hpp>
16 requires std::is_floating_point_v<T>
20 requires std::is_arithmetic_v<T>
24 requires std::is_arithmetic_v<T>
25 [[nodiscard]] T
Dot(
const Vec3<T>& left,
const Vec3<T>& right)
noexcept;
28 requires std::is_arithmetic_v<T>
29 [[nodiscard]] Vec3<T>
Cross(
const Vec3<T>& left,
30 const Vec3<T>& right)
noexcept;
33 requires std::is_arithmetic_v<T>
34 [[nodiscard]] Vec3<T>
Min(
const Vec3<T>& left,
35 const Vec3<T>& right)
noexcept;
38 requires std::is_arithmetic_v<T>
39 [[nodiscard]] Vec3<T>
Max(
const Vec3<T>& left,
40 const Vec3<T>& right)
noexcept;
43 requires std::is_arithmetic_v<T>
44 class alignas(sizeof(T) * 4U)
Vec3
47 using Ops = detail::SelectedVectorOps<T>;
59 Native_ = Ops::Load3(
values);
63 requires(std::is_arithmetic_v<U> && !std::is_same_v<T, U>)
72 requires std::is_arithmetic_v<U>
110 return Ops::GetX(Native_);
115 return Ops::GetY(Native_);
120 return Ops::GetZ(Native_);
137 template <std::
size_t Index>
140 static_assert(
Index < 3U);
141 if constexpr (
Index == 0
U)
145 else if constexpr (
Index == 1U)
172 Native_ = Ops::SetX(Native_,
value);
177 Native_ = Ops::SetY(Native_,
value);
182 Native_ = Ops::SetZ(Native_,
value);
203 template <std::
size_t Index>
206 static_assert(
Index < 3U);
207 if constexpr (
Index == 0
U)
211 else if constexpr (
Index == 1U)
223 return Vec3(Ops::Add(Native_,
other.Native_));
228 return Vec3(Ops::Subtract(Native_,
other.Native_));
233 return Vec3(Ops::Multiply(Native_,
other.Native_));
243 return Vec3(Ops::Divide3(Native_,
other.Native_));
263 return Vec3(Ops::Negate(Native_));
268 Native_ = Ops::Add(Native_,
other.Native_);
274 Native_ = Ops::Subtract(Native_,
other.Native_);
280 Native_ = Ops::Multiply(Native_,
other.Native_);
286 Native_ = Ops::Divide3(Native_,
other.Native_);
292 Native_ = Ops::Add(Native_,
scalar);
298 Native_ = Ops::Subtract(Native_,
scalar);
304 Native_ = Ops::Multiply(Native_,
scalar);
310 Native_ = Ops::Divide(Native_,
scalar);
332 inline static constexpr T Zero_[4] = {T(0), T(0), T(0), T(0)};
333 typename Ops::Native Native_;
335 friend T Dot<T>(
const Vec3&,
const Vec3&)
noexcept;
336 friend Vec3 Cross<T>(
const Vec3&,
const Vec3&)
noexcept;
339 template <
typename U>
340 requires std::is_floating_point_v<U>
357 template <
typename T>
358 requires std::is_arithmetic_v<T>
361 using Ops = detail::SelectedVectorOps<T>;
362 return Ops::Dot3(
left.Native_,
right.Native_);
365 template <
typename T>
366 requires std::is_arithmetic_v<T>
370 using Ops = detail::SelectedVectorOps<T>;
374 template <
typename T>
380 template <
typename T>
381 requires std::is_floating_point_v<T>
392 template <
typename T>
393 requires std::is_floating_point_v<T>
403 template <
typename T>
404 requires std::is_floating_point_v<T>
411 template <
typename T>
418 template <
typename T>
419 requires std::is_floating_point_v<T>
426 template <
typename T>
427 requires std::is_arithmetic_v<T>
431 using Ops = detail::SelectedVectorOps<T>;
435 template <
typename T>
436 requires std::is_arithmetic_v<T>
440 using Ops = detail::SelectedVectorOps<T>;
444 template <
typename T>
453 template <
typename T>
461 template <
typename T>
462 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
466 static_cast<T>(std::abs(
value.Y())),
467 static_cast<T>(std::abs(
value.Z())));
470 template <
typename T>
471 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
482 template <
typename T>
483 requires std::is_floating_point_v<T>
492 template <
typename T>
493 requires std::is_floating_point_v<T>
504static_assert(std::is_trivially_copyable_v<mv::math::Vec3f>);
505static_assert(std::is_standard_layout_v<mv::math::Vec3f>);
Vec3 operator/(const Vec3 &other) const noexcept
Vec2< T > YZ() const noexcept
void SetX(T value) noexcept
Vec3 operator*(T scalar) const noexcept
static Vec3 Filled(T value) noexcept
Vec2< T > XY() const noexcept
Vec3 operator*(const Vec3 &other) const noexcept
Vec3 operator-(const Vec3 &other) const noexcept
Vec3 & operator/=(const Vec3 &other) noexcept
static Vec3 AxisY() noexcept
Vec3(const Vec2< U > &xy, T z=T(0)) noexcept
Vec3 operator+(T scalar) const noexcept
static Vec3 One() noexcept
static Vec3 AxisZ() noexcept
Vec3 & operator-=(T scalar) noexcept
Vec3 & operator-=(const Vec3 &other) noexcept
bool SetComponent(std::size_t index, T value) noexcept
Vec3(T x, T y, T z) noexcept
Vec3 operator-(T scalar) const noexcept
Vec3 & operator*=(const Vec3 &other) noexcept
Vec2< T > XZ() const noexcept
friend Vec3 operator*(T scalar, const Vec3 &vector) noexcept
void SetY(T value) noexcept
T operator[](std::size_t index) const noexcept
Vec3 & operator+=(T scalar) noexcept
void SetZ(T value) noexcept
Vec3(const Vec3< U > &other) noexcept
Vec3 operator/(T scalar) const noexcept
Vec3 & operator/=(T scalar) noexcept
friend bool operator==(const Vec3 &left, const Vec3 &right) noexcept
void Set(T value) noexcept
static Vec3 Zero() noexcept
static Vec3 AxisX() noexcept
Vec3 & operator+=(const Vec3 &other) noexcept
Vec3 operator-() const noexcept
Vec3 & operator*=(T scalar) noexcept
Vec3 operator+(const Vec3 &other) const noexcept
Vec2< T > Sign(const Vec2< T > &value) noexcept
constexpr T Dot(const Quat< T > &left, const Quat< T > &right) noexcept
Vec2< T > LerpUnclamped(const Vec2< T > &from, const Vec2< T > &to, T amount) noexcept
Vec3< T > Cross(const Vec3< T > &left, const Vec3< T > &right) noexcept
T Distance(const Point3< T > &point, const Line3< T > &line) noexcept
bool IsNearlyEqual(const Quat< T > &left, const Quat< T > &right, Tolerance< T > tolerance=Tolerance< T >::Default()) noexcept
constexpr T LengthSquared(const Quat< T > &value) noexcept
Vec2< T > Min(const Vec2< T > &left, const Vec2< T > &right) noexcept
Vec3< std::int32_t > Vec3i32
Vec2< T > Clamp(const Vec2< T > &value, const Vec2< T > &minimum, const Vec2< T > &maximum) noexcept
T Length(const Quat< T > &value) noexcept
constexpr bool IsNearlyZero(T value, T absoluteTolerance=Tolerance< T >::Default().Absolute) noexcept
Vec2< T > Max(const Vec2< T > &left, const Vec2< T > &right) noexcept
Vec3< std::uint32_t > Vec3u32
Vec2< T > Lerp(const Vec2< T > &from, const Vec2< T > &to, T amount) noexcept
Vec2< T > Abs(const Vec2< T > &value) noexcept
T DistanceSquared(const Point3< T > &point, const Line3< T > &line) noexcept