22#include <kiwano/math/Scalar.h>
28template <
typename _Ty>
31 using ValueType = _Ty;
42 Vec2T(ValueType x, ValueType y)
54 inline ValueType Length()
const
56 return static_cast<ValueType
>(math::Sqrt(
static_cast<float>(x * x + y * y)));
59 inline bool IsOrigin()
const
61 return (x == 0) && (y == 0);
64 inline void Set(ValueType x, ValueType y)
70 inline const Vec2T operator+(
const Vec2T& other)
const
72 return Vec2T(x + other.x, y + other.y);
75 inline const Vec2T operator-(
const Vec2T& other)
const
77 return Vec2T(x - other.x, y - other.y);
80 inline const Vec2T operator*(ValueType val)
const
82 return Vec2T(x * val, y * val);
85 inline const Vec2T operator/(ValueType val)
const
87 return Vec2T(x / val, y / val);
90 inline const Vec2T operator-()
const
109 inline Vec2T& operator*=(ValueType val)
116 inline Vec2T& operator/=(ValueType val)
123 inline bool operator==(
const Vec2T& other)
const
125 return (x == other.x) && (y == other.y);
128 inline bool operator!=(
const Vec2T& other)
const
130 return (x != other.x) || (y != other.y);