24 template<typename = typename std::enable_if<std::is_convertible<decltype(std::declval<T>() == std::declval<T>()),
bool>::value>::type>
25 bool operator==(
const Vector2& other)
const {
return x == other.
x &&
y == other.
y; }
27 template<typename = typename std::enable_if<std::is_convertible<decltype(std::declval<T>() == std::declval<T>()),
bool>::value>::type>
28 bool operator!=(
const Vector2& other)
const {
return !(*
this == other); }
31 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
34 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
37 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
40 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
44 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
47 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
50 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
53 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
57 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
61 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
64 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
67 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
70 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
71 typename std::conditional<std::is_floating_point<T>::value, T,
double>::type
74 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
75 typename std::conditional<std::is_floating_point<T>::value, T,
double>::type
78 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
80 double dot = double(this->
dot(other));
86 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
89 if (len == 0)
return {0, 0};
90 return {T(
x / len), T(
y / len)};
93 template<typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
102 template<typename U = T, typename = typename std::enable_if<std::is_floating_point<U>::value>::type>
104 return std::abs(
x - other.
x) < epsilon &&
105 std::abs(
y - other.
y) < epsilon;
constexpr T epsilon_v
Definition Constants.hpp:32
Vector2< std::int32_t > Vector2i
Definition Vector2.hpp:111
Vector2< double > Vector2f
Definition Vector2.hpp:112
Vector2< std::uint32_t > Vector2u
Definition Vector2.hpp:110
Definition Vector2.hpp:20
Vector2 operator/(T scalar) const
Definition Vector2.hpp:41
void normalize()
Definition Vector2.hpp:94
Vector2 & operator+=(const Vector2 &other)
Definition Vector2.hpp:45
Vector2 & operator*=(T scalar)
Definition Vector2.hpp:51
T y
Definition Vector2.hpp:21
bool same(const Vector2 &other, T epsilon=epsilon_v< T >) const
Definition Vector2.hpp:103
std::uint32_t x
Definition Vector2.hpp:21
Vector2 & operator-=(const Vector2 &other)
Definition Vector2.hpp:48
T cross(const Vector2 &other) const
Definition Vector2.hpp:65
Vector2 operator-(const Vector2 &other) const
Definition Vector2.hpp:35
Vector2 operator+(const Vector2 &other) const
Definition Vector2.hpp:32
Vector2 operator-() const
Definition Vector2.hpp:58
T square_magnitude() const
Definition Vector2.hpp:68
std::conditional< std::is_floating_point< T >::value, T, double >::type magnitude() const
Definition Vector2.hpp:72
std::conditional< std::is_floating_point< T >::value, T, double >::type distance(const Vector2 &other) const
Definition Vector2.hpp:76
Vector2 normalized() const
Definition Vector2.hpp:87
Vector2 & operator/=(T scalar)
Definition Vector2.hpp:54
T dot(const Vector2 &other) const
Definition Vector2.hpp:62
double angle(const Vector2 &other) const
Definition Vector2.hpp:79
Vector2 operator*(T scalar) const
Definition Vector2.hpp:38