11#include <mv/math/detail/VectorOps.hpp>
16 requires std::is_arithmetic_v<T>
17 class alignas(sizeof(T) * 2U)
Vec2
29 requires(std::is_arithmetic_v<U> && !std::is_same_v<T, U>)
31 Components_{
static_cast<T>(
other.X()),
static_cast<T>(
other.Y())}
62 return Components_[0];
67 return Components_[1];
73 return Components_[index];
76 template <std::
size_t Index>
79 static_assert(
Index < 2U);
80 return Components_[
Index];
85 Components_[0] =
value;
90 Components_[1] =
value;
100 Components_[index] =
value;
104 template <std::
size_t Index>
107 static_assert(
Index < 2U);
113 return FromNative(Ops::Add(Ops::Load2(Components_),
114 Ops::Load2(
other.Components_)));
119 return FromNative(Ops::Subtract(Ops::Load2(Components_),
120 Ops::Load2(
other.Components_)));
125 return FromNative(Ops::Multiply(Ops::Load2(Components_),
126 Ops::Load2(
other.Components_)));
131 return FromNative(Ops::Divide2(Ops::Load2(Components_),
132 Ops::Load2(
other.Components_)));
137 return FromNative(Ops::Add(Ops::Load2(Components_),
scalar));
142 return FromNative(Ops::Subtract(Ops::Load2(Components_),
scalar));
147 return FromNative(Ops::Multiply(Ops::Load2(Components_),
scalar));
152 return FromNative(Ops::Divide(Ops::Load2(Components_),
scalar));
157 return FromNative(Ops::Negate(Ops::Load2(Components_)));
162 *
this = *
this +
other;
168 *
this = *
this -
other;
174 *
this = *
this *
other;
180 *
this = *
this /
other;
215 const Vec2&,
const Vec2&)
noexcept =
default;
221 using Ops = detail::ScalarVectorOps<T>;
224 typename Ops::Native
value)
noexcept
247 template <
typename T>
250 using Ops = detail::ScalarVectorOps<T>;
256 template <
typename T>
262 template <
typename T>
263 requires std::is_floating_point_v<T>
273 template <
typename T>
274 requires std::is_floating_point_v<T>
283 template <
typename T>
284 requires std::is_floating_point_v<T>
291 template <
typename T>
298 template <
typename T>
299 requires std::is_floating_point_v<T>
306 template <
typename T>
314 template <
typename T>
322 template <
typename T>
331 template <
typename T>
339 template <
typename T>
340 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
344 static_cast<T>(std::abs(
value.Y())));
347 template <
typename T>
348 requires(std::is_signed_v<T> || std::is_floating_point_v<T>)
359 template <
typename T>
360 requires std::is_floating_point_v<T>
369 template <
typename T>
370 requires std::is_floating_point_v<T>
381static_assert(std::is_trivially_copyable_v<mv::math::Vec2f>);
382static_assert(std::is_standard_layout_v<mv::math::Vec2f>);
Vec2 operator-() const noexcept
constexpr void SetY(T value) noexcept
Vec2 operator*(T scalar) const noexcept
Vec2 operator+(const Vec2 &other) const noexcept
Vec2 & operator/=(T scalar) noexcept
constexpr T operator[](std::size_t index) const noexcept
Vec2 & operator*=(T scalar) noexcept
constexpr T X() const noexcept
constexpr T Y() const noexcept
constexpr T Get() const noexcept
static constexpr Vec2 Zero() noexcept
Vec2 operator-(const Vec2 &other) const noexcept
constexpr void SetX(T value) noexcept
static constexpr Vec2 One() noexcept
static constexpr Vec2 Filled(T value) noexcept
constexpr void Set(T value) noexcept
Vec2 operator-(T scalar) const noexcept
Vec2 operator/(const Vec2 &other) const noexcept
Vec2 & operator-=(T scalar) noexcept
friend Vec2 operator*(T scalar, const Vec2 &vector) noexcept
Vec2 & operator*=(const Vec2 &other) noexcept
constexpr Vec2(const Vec2< U > &other) noexcept
Vec2 operator*(const Vec2 &other) const noexcept
constexpr bool SetComponent(std::size_t index, T value) noexcept
Vec2 & operator-=(const Vec2 &other) noexcept
Vec2 & operator/=(const Vec2 &other) noexcept
Vec2 & operator+=(const Vec2 &other) noexcept
constexpr Vec2() noexcept=default
friend constexpr bool operator==(const Vec2 &, const Vec2 &) noexcept=default
Vec2 operator+(T scalar) const noexcept
Vec2 & operator+=(T scalar) noexcept
Vec2 operator/(T scalar) const noexcept
static constexpr Vec2 AxisX() noexcept
static constexpr Vec2 AxisY() noexcept
Vec2< T > Sign(const Vec2< T > &value) noexcept
Vec2< std::int32_t > Vec2i32
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
Vec2< std::uint32_t > Vec2u32
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