11 #include <type_traits> 26 constexpr
TPoint() =
default;
30 : TPoint(static_cast<
Type>(other.x), static_cast<
Type>(other.y)) {}
42 return p.
x == x && p.
y ==
y;
46 return p.
x != x || p.
y !=
y;
51 x +=
static_cast<Type>(p.
x);
52 y +=
static_cast<Type>(p.
y);
65 x -=
static_cast<Type>(p.
x);
66 y -=
static_cast<Type>(p.
y);
79 x *=
static_cast<Type>(p.
x);
80 y *=
static_cast<Type>(p.
y);
91 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
93 x *=
static_cast<Type>(scale);
94 y *=
static_cast<Type>(scale);
100 x /=
static_cast<Type>(p.
x);
101 y /=
static_cast<Type>(p.
y);
112 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
114 x /=
static_cast<Type>(scale);
115 y /=
static_cast<Type>(scale);
122 return {x + p.
x, y + p.
y};
127 return {x +
static_cast<Type>(s.
width), y + static_cast<Type>(s.
height)};
131 return {x - p.
x, y - p.
y};
136 return {x -
static_cast<Type>(s.
width), y - static_cast<Type>(s.
height)};
139 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
141 return {
static_cast<Type>(x * scale), static_cast<Type>(y * scale)};
145 return {x * p.
x, y * p.
y};
150 return {x *
static_cast<Type>(s.
width), y * static_cast<Type>(s.
height)};
153 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
155 return {
static_cast<Type>(x /
d), static_cast<Type>(y / d)};
159 return {x / p.
x, y / p.
y};
164 return {x /
static_cast<Type>(s.
width), y / static_cast<Type>(s.
height)};
170 return dx * dx + dy * dy;
174 return {std::min<Type>(
x, p.
x), std::min<Type>(y, p.
y)};
178 return {std::max<Type>(
x, p.
x), std::max<Type>(y, p.
y)};
197 constexpr
TPoint Abs()
const {
return {std::fabs(x), std::fabs(y)}; }
204 return *
this - axis * this->
Dot(axis) * 2;
207 constexpr
bool IsZero()
const {
return x == 0 && y == 0; }
212 template <
class F,
class I,
class = MixedOp<F, I>>
214 return {p1.
x +
static_cast<F
>(p2.
x), p1.
y + static_cast<F>(p2.
y)};
217 template <
class F,
class I,
class = MixedOp<F, I>>
222 template <
class F,
class I,
class = MixedOp<F, I>>
224 return {p1.
x -
static_cast<F
>(p2.
x), p1.
y - static_cast<F>(p2.
y)};
227 template <
class F,
class I,
class = MixedOp<F, I>>
229 return {
static_cast<F
>(p1.
x) - p2.
x, static_cast<F>(p1.
y) - p2.
y};
232 template <
class F,
class I,
class = MixedOp<F, I>>
234 return {p1.
x *
static_cast<F
>(p2.
x), p1.
y * static_cast<F>(p2.
y)};
237 template <
class F,
class I,
class = MixedOp<F, I>>
242 template <
class F,
class I,
class = MixedOp<F, I>>
244 return {p1.
x /
static_cast<F
>(p2.
x), p1.
y / static_cast<F>(p2.
y)};
247 template <
class F,
class I,
class = MixedOp<F, I>>
249 return {
static_cast<F
>(p1.
x) / p2.
x, static_cast<F>(p1.
y) / p2.
y};
254 template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
259 template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
261 return {
static_cast<T
>(s) / p.
x, static_cast<T>(s) / p.
y};
266 template <
class T,
class U>
271 template <
class T,
class U>
273 return {
static_cast<T
>(s.
width) - p.
x, static_cast<T>(s.
height) - p.
y};
276 template <
class T,
class U>
281 template <
class T,
class U>
283 return {
static_cast<T
>(s.
width) / p.
x, static_cast<T>(s.
height) / p.
y};
297 out <<
"(" << p.
x <<
", " << p.
y <<
")";
constexpr TPoint Reflect(const TPoint &axis) const
constexpr TPoint(const TPoint< U > &other)
TPoint operator/=(const TPoint< U > &p)
constexpr Type Dot(const TPoint &p) const
constexpr TPoint operator/(const TSize< U > &s) const
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
constexpr TPoint Normalize() const
constexpr bool operator==(const TPoint &p) const
constexpr Type GetLengthSquared() const
constexpr Type Cross(const TPoint &p) const
TPoint operator*=(const TSize< U > &s)
TPoint operator-=(const TPoint< U > &p)
constexpr TPoint operator/(const TPoint &p) const
constexpr TPoint()=default
constexpr TPoint Abs() const
constexpr TPoint operator*(U scale) const
constexpr TPoint Max(const TPoint &p) const
TPoint operator*=(U scale)
constexpr Type GetDistance(const TPoint &p) const
static constexpr TPoint< Type > MakeXY(Type x, Type y)
constexpr TPoint operator*(const TSize< U > &s) const
std::ostream & operator<<(std::ostream &out, const impeller::TPoint< T > &p)
constexpr TPoint operator-() const
constexpr TPoint operator+(const TSize< U > &s) const
constexpr TPoint(Type x, Type y)
constexpr TPoint(const TSize< U > &other)
constexpr TPoint operator*(const TPoint &p) const
TPoint operator+=(const TPoint< U > &p)
TPoint operator/=(const TSize< U > &s)
TPoint operator/=(U scale)
constexpr TPoint operator-(const TSize< U > &s) const
constexpr bool IsZero() const
TPoint operator-=(const TSize< U > &s)
TPoint operator+=(const TSize< U > &s)
constexpr TPoint operator-(const TPoint &p) const
constexpr Type GetLength() const
constexpr bool operator!=(const TPoint &p) const
constexpr TPoint operator/(U d) const
constexpr Type GetDistanceSquared(const TPoint &p) const
constexpr TPoint Min(const TPoint &p) const
TPoint operator*=(const TPoint< U > &p)
constexpr TPoint operator+(const TPoint &p) const