12#include <mv/math/detail/VectorOps.hpp>
17 requires std::is_floating_point_v<T>
21 requires std::is_arithmetic_v<T>
22 class alignas(sizeof(T) * 4U)
Vec4
34 requires(std::is_arithmetic_v<U> && !std::is_same_v<T, U>)
36 Components_{
static_cast<T>(
other.X()),
static_cast<T>(
other.Y()),
42 requires std::is_arithmetic_v<U>
46 Components_{
static_cast<T>(
xy.X()),
static_cast<T>(
xy.Y()),
z,
w}
51 requires std::is_arithmetic_v<U>
53 Components_{
static_cast<T>(
xyz.X()),
static_cast<T>(
xyz.Y()),
54 static_cast<T>(
xyz.Z()),
w}
95 return Components_[0];
99 return Components_[1];
103 return Components_[2];
107 return Components_[3];
113 return Components_[index];
116 template <std::
size_t Index>
119 static_assert(
Index < 4U);
120 return Components_[
Index];
130 Components_[index] =
value;
134 template <std::
size_t Index>
137 static_assert(
Index < 4U);
158 return FromNative(Ops::Add(Ops::Load4(Components_),
159 Ops::Load4(
other.Components_)));
164 return FromNative(Ops::Subtract(Ops::Load4(Components_),
165 Ops::Load4(
other.Components_)));
170 return FromNative(Ops::Multiply(Ops::Load4(Components_),
171 Ops::Load4(
other.Components_)));
176 return FromNative(Ops::Divide(Ops::Load4(Components_),
177 Ops::Load4(
other.Components_)));
182 return FromNative(Ops::Add(Ops::Load4(Components_),
scalar));
187 return FromNative(Ops::Subtract(Ops::Load4(Components_),
scalar));
192 return FromNative(Ops::Multiply(Ops::Load4(Components_),
scalar));
197 return FromNative(Ops::Divide(Ops::Load4(Components_),
scalar));
202 return FromNative(Ops::Negate(Ops::Load4(Components_)));
207 *
this = *
this +
other;
213 *
this = *
this -
other;
219 *
this = *
this *
other;
225 *
this = *
this /
other;
260 const Vec4&,
const Vec4&)
noexcept =
default;
263 using Ops = detail::SelectedVectorOps<T>;
266 typename Ops::Native
value)
noexcept
275 template <
typename U>
276 requires std::is_floating_point_v<U>
293 template <
typename T>
296 using Ops = detail::SelectedVectorOps<T>;
302 template <
typename T>
308 template <
typename T>
309 requires std::is_floating_point_v<T>
321 template <
typename T>
322 requires std::is_floating_point_v<T>
333 template <
typename T>
334 requires std::is_floating_point_v<T>
341 template <
typename T>
348 template <
typename T>
349 requires std::is_floating_point_v<T>
356 template <
typename T>
365 template <
typename T>
374 template <
typename T>
383 template <
typename T>
391 template <
typename T>
392 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
396 static_cast<T>(std::abs(
value.Y())),
397 static_cast<T>(std::abs(
value.Z())),
398 static_cast<T>(std::abs(
value.W())));
401 template <
typename T>
402 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
414 template <
typename T>
415 requires std::is_floating_point_v<T>
424 template <
typename T>
425 requires std::is_floating_point_v<T>
436static_assert(std::is_trivially_copyable_v<mv::math::Vec4f>);
437static_assert(std::is_standard_layout_v<mv::math::Vec4f>);
Vec4 operator*(T scalar) const noexcept
Vec4 operator/(T scalar) const noexcept
Vec4 & operator+=(const Vec4 &other) noexcept
Vec4 operator+(T scalar) const noexcept
constexpr T Get() const noexcept
constexpr T operator[](std::size_t index) const noexcept
friend Vec4 operator*(T scalar, const Vec4 &vector) noexcept
static constexpr Vec4 AxisY() noexcept
Vec4 operator-(T scalar) const noexcept
Vec4 operator-() const noexcept
Vec4 & operator/=(T scalar) noexcept
Vec4 operator/(const Vec4 &other) const noexcept
Vec4 operator*(const Vec4 &other) const noexcept
Vec4 operator-(const Vec4 &other) const noexcept
constexpr Vec4() noexcept=default
Vec4(const Vec3< U > &xyz, T w=T(0)) noexcept
constexpr T Z() const noexcept
Vec4 & operator-=(const Vec4 &other) noexcept
Vec4 operator+(const Vec4 &other) const noexcept
Vec4 & operator*=(T scalar) noexcept
constexpr T Y() const noexcept
static constexpr Vec4 AxisW() noexcept
constexpr Vec2< T > ZW() const noexcept
static constexpr Vec4 AxisX() noexcept
static constexpr Vec4 One() noexcept
Vec4 & operator+=(T scalar) noexcept
Vec4 & operator-=(T scalar) noexcept
constexpr Vec2< T > XY() const noexcept
constexpr Vec4(const Vec4< U > &other) noexcept
constexpr Vec4(const Vec2< U > &xy, T z=T(0), T w=T(0)) noexcept
static constexpr Vec4 Filled(T value) noexcept
Vec4 & operator/=(const Vec4 &other) noexcept
constexpr T W() const noexcept
constexpr T X() const noexcept
Vec3< T > XYZ() const noexcept
friend constexpr bool operator==(const Vec4 &, const Vec4 &) noexcept=default
static constexpr Vec4 AxisZ() noexcept
Vec4 & operator*=(const Vec4 &other) noexcept
constexpr void Set(T value) noexcept
static constexpr Vec4 Zero() noexcept
constexpr bool SetComponent(std::size_t index, T value) noexcept
Vec2< T > Sign(const Vec2< T > &value) noexcept
constexpr T Dot(const Quat< T > &left, const Quat< T > &right) noexcept
Vec4< std::uint32_t > Vec4u32
Vec2< T > LerpUnclamped(const Vec2< T > &from, const Vec2< T > &to, T amount) noexcept
Vec4< std::int32_t > Vec4i32
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
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
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