33 [[nodiscard]]
static JPL_INLINE
constexpr Vec2 Zero() noexcept {
return Vec2{ 0.0f, 0.0f }; }
35 [[nodiscard]] JPL_INLINE
constexpr float LengthSquared() const noexcept {
return X *
X +
Y *
Y; }
49 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
50 [[nodiscard]] JPL_INLINE
constexpr Vec2 operator*(Arg Scale)
const noexcept {
return Vec2{
X * (float)Scale,
Y * (
float)Scale }; }
51 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
52 [[nodiscard]] JPL_INLINE
constexpr Vec2 operator/(Arg Scale)
const noexcept {
const float invScale = 1.0f / (float)Scale;
return Vec2{
X * invScale,
Y * invScale }; }
53 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
54 JPL_INLINE
constexpr Vec2&
operator/=(Arg Scale)
noexcept {
const float invScale = 1.0f / (float)Scale;
X *= invScale;
Y *= invScale;
return *
this; }
59 [[nodiscard]] JPL_INLINE
constexpr bool operator==(
const Vec2& A,
const Vec2& B)
noexcept {
return A.X == B.X && A.Y == B.Y; }
61 template<
typename T>
requires(std::is_arithmetic_v<T>)
62 [[nodiscard]] JPL_INLINE
constexpr Vec2 operator*(T Scale,
const JPL::Vec2& V)
noexcept {
return V.operator*(Scale); }
63 template<
typename T>
requires(std::is_arithmetic_v<T>)
64 [[nodiscard]] JPL_INLINE
constexpr Vec2 operator/(T Scale,
const JPL::Vec2& V)
noexcept {
return V.operator/(Scale); }
69 [[nodiscard]]
static JPL_INLINE
constexpr float CrossProduct(
const Vec2& a,
const Vec2& b)
noexcept {
return a.X * b.Y - a.Y * b.X; }
70 [[nodiscard]]
static JPL_INLINE
constexpr float DotProduct(
const Vec2& a,
const Vec2& b)
noexcept {
return a.X * b.X + a.Y * b.Y; }
71 [[nodiscard]]
static JPL_INLINE
constexpr Vec2 Normalized(
const Vec2& V)
noexcept {
return Vec2(V).Normalize(); }
73 static JPL_INLINE
constexpr Vec2& Normalize(Vec2& V)
noexcept {
return V.
Normalize(); }
75 [[nodiscard]]
static JPL_INLINE
constexpr Vec2
Abs(
const Vec2& V)
noexcept {
return {
Math::Abs(V.
X),
Math::Abs(V.
Y) }; }
77 inline std::ostream&
operator<<(std::ostream& os,
const Vec2& v) { os <<
"{ " << v.
X <<
", " << v.
Y <<
" }";
return os; }
JPL_INLINE constexpr T InvSqrt(T x) noexcept
Definition Math.h:283
JPL_INLINE constexpr T Sqrt(T x) noexcept
Definition Math.h:269
JPL_INLINE constexpr auto Abs(const T &value) noexcept
Standard abs is not constexpr in C++20.
Definition Math.h:87
Definition AcousticMaterial.h:36
JPL_INLINE constexpr Vec2 operator/(T Scale, const JPL::Vec2 &V) noexcept
Definition MinimalVec2.h:64
JPL_INLINE constexpr bool operator==(const Vec2 &A, const Vec2 &B) noexcept
Definition MinimalVec2.h:59
JPL_INLINE constexpr Vec2 operator*(T Scale, const JPL::Vec2 &V) noexcept
Definition MinimalVec2.h:62
std::ostream & operator<<(std::ostream &os, const AcousticMaterial &v)
Definition AcousticMaterial.h:104
Definition MinimalVec2.h:29
JPL_INLINE constexpr Vec2 operator-(const Vec2 &V) const noexcept
Definition MinimalVec2.h:46
JPL_INLINE constexpr Vec2 & Normalize() noexcept
Definition MinimalVec2.h:37
JPL_INLINE constexpr float Length() const noexcept
Definition MinimalVec2.h:36
static JPL_INLINE constexpr Vec2 Zero() noexcept
Definition MinimalVec2.h:33
float X
Definition MinimalVec2.h:30
JPL_INLINE constexpr Vec2 operator+(const Vec2 &V) const noexcept
Definition MinimalVec2.h:47
JPL_INLINE constexpr float LengthSquared() const noexcept
Definition MinimalVec2.h:35
JPL_INLINE constexpr Vec2 operator-() const noexcept
Definition MinimalVec2.h:45
JPL_INLINE constexpr void operator+=(const Vec2 &V) noexcept
Definition MinimalVec2.h:56
float Y
Definition MinimalVec2.h:31