11 public sequence_type < NUMBER, 2 >
16 using UNIT_TYPE = NUMBER;
29 consteval point2_t semantic_t()
const {
return {}; }
38 template < prototype_number A >
46 template < prototype_number X, prototype_number Y >
49 this->m_coordinatea[0] = (UNIT_TYPE) x;
50 this->m_coordinatea[1] = (UNIT_TYPE) y;
53 template < prototype_number NUMBER1 >
54 constexpr point_type(
const sequence_type < NUMBER1, 2 > & sequence) :
55 sequence_type < UNIT_TYPE, 2 >(sequence)
150 constexpr bool is_same_by(UNIT_TYPE e,
const point_type & p)
const
153 return ::std::abs(this->x - p.x) < ::std::abs(e)
154 && ::std::abs(this->y - p.y) < ::std::abs(e);
159 inline point_type & operator = (const ::point_type < UNIT_TYPE > & point) { this->x = point.x; this->y = point.y;
return *
this; }
165 ::u32 as_u32() const noexcept {
return as_u32(this->x, this->y); }
166 ::u64 as_u64() const noexcept {
return as_u64(this->x, this->y); }
169 point_type& clear() { this->x = (UNIT_TYPE)0; this->y = (UNIT_TYPE) 0;
return *
this; }
172 point_type & offset(UNIT_TYPE xOffset, UNIT_TYPE yOffset)
noexcept { this->x += xOffset; this->y += yOffset;
return *
this; }
173 point_type & offset(
const sequence_type < UNIT_TYPE, 2 > & sequence)
noexcept { this->x += sequence.x; this->y += sequence.y;
return *
this; }
175 point_type & set(UNIT_TYPE x, UNIT_TYPE y)
noexcept { this->x = x; this->y = y;
return *
this; }
192 template < prototype_po
int POINT >
193 ::f64 distance(
const POINT& point)
const {
auto s = *
this - point;
return sqrt((::f64) (s.cx * s.cx + s.cy * s.cy)); }
195 template < prototype_po
int POINT >
198 return { (UNIT_TYPE)((this->x + point.x) / (UNIT_TYPE)2), (UNIT_TYPE)((this->y + point.y) / (UNIT_TYPE)2) };
202 template < prototype_po
int POINT >
203 inline bool operator==(
const POINT & point)
const noexcept {
return (this->x == (UNIT_TYPE) point.x && this->y == (UNIT_TYPE) point.y); }
209 inline bool operator==(nullptr_t)
const noexcept { return ::is_null(
this); }
212 template < prototype_number NUMBER1 >
216 result[0] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[0] * n);
217 result[1] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[1] * n);
222 template < prototype_number NUMBER1 >
226 result[0] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[0] / n);
227 result[1] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[1] / n);
232 template < prototype_size SIZE >
233 inline point_type& operator +=(
const SIZE& size)
noexcept { this->x = (UNIT_TYPE) (this->x + size.cx); this->y = (UNIT_TYPE)(this->y + size.cy);
return *
this; }
235 template < prototype_size SIZE >
236 inline point_type& operator -=(
const SIZE& size)
noexcept { this->x = (UNIT_TYPE)(this->x - size.cx); this->y = (UNIT_TYPE)(this->y - size.cy);
return *
this; }
238 template < prototype_po
int POINT >
239 inline point_type& operator +=(
const POINT& point)
noexcept { this->x = (UNIT_TYPE)(this->x + point.x); this->y = (UNIT_TYPE)(this->y + point.y);
return *
this; }
241 template < prototype_po
int POINT >
242 inline point_type& operator -=(
const POINT& point)
noexcept { this->x = (UNIT_TYPE)(this->x - point.x); this->y = (UNIT_TYPE)(this->y - point.y);
return *
this; }
244 template < prototype_number NUMBER1 >
251 template < prototype_number NUMBER1 >
318 inline bool operator < (
const point_type& point)
const noexcept
321 auto d = this->y - point.y;
323 if (d < 0)
return true;
325 if (d > 0)
return false;
327 return this->x < point.x;
335 return this->x == 0 && this->y == 0;
340 template < prototype_po
int POINT >
341 void expand_bounding_box(POINT & top_left, POINT & bottom_right)
const
344 expand_minimum_maximum(top_left.x, bottom_right.x, this->x);
346 expand_minimum_maximum(top_left.y, bottom_right.y, this->y);
351 template < prototype_po
int POINT >
352 static void expand_bounding_box(POINT & top_left, POINT & bottom_right,
const point_type * ppoint, ::collection::count count)
358 ppoint->expand_bounding_box(top_left, bottom_right);
457 bool m_bIncludeParenthesis =
false;
458 bool m_bIncludeNames =
false;
461 constexpr bool check_option(
auto &it,
const auto & end)
469 m_bIncludeParenthesis =
true;
475 m_bIncludeNames =
true;
482 throw std::format_error(
"Invalid format specifier for Point.");
495 constexpr auto parse(std::format_parse_context& ctx) {
496 auto it = ctx.begin(), end = ctx.end();
497 while (check_option(it, end));
505 if (m_bIncludeParenthesis) {
506 return std::format_to(ctx.out(),
"(x:{}, y:{})", point.x, point.y);
508 return std::format_to(ctx.out(),
"x:{}, y:{}", point.x, point.y);
513 if (m_bIncludeParenthesis) {
514 return std::format_to(ctx.out(),
"({}, {})", point.x, point.y);
516 return std::format_to(ctx.out(),
"{}, {}", point.x, point.y);