234struct sequence_type :
239 using sequence_size = sequence_size_t < t_iSize >;
241 using COORDINATE =
typename SEQUENCE_T::COORDINATE;
242 using UNIT_TYPE =
typename SEQUENCE_T::COORDINATE;
243 static const ::i32 SIZE = t_iSize;
246 static constexpr bool IS_MATRIX =
false;
249 constexpr sequence_type()
263 constexpr sequence_type(UNIT_TYPE n)
271 template < prototype_sequence2 S2 >
272 constexpr sequence_type(
const S2 & s2)
275 this->m_coordinatea[0] = (UNIT_TYPE) s2.x;
276 this->m_coordinatea[1] = (UNIT_TYPE) s2.y;
280 template < prototype_sequence3 S3 >
281 constexpr sequence_type(
const S3 & s3)
284 this->m_coordinatea[0] = (UNIT_TYPE) s3.x;
285 this->m_coordinatea[1] = (UNIT_TYPE) s3.y;
286 this->m_coordinatea[2] = (UNIT_TYPE) s3.z;
290 template<prototype_sequence4 S4>
291 constexpr sequence_type(
const S4 &s4)
294 this->m_coordinatea[0] = (UNIT_TYPE)s4.x;
295 this->m_coordinatea[1] = (UNIT_TYPE)s4.y;
296 this->m_coordinatea[2] = (UNIT_TYPE)s4.z;
297 this->m_coordinatea[3] = (UNIT_TYPE)s4.w;
300 template<prototype_number NUMBER1>
301 constexpr sequence_type(
const NUMBER1 *p)
303 for (::collection::count i = 0; i < SIZE; ++i)
304 this->m_coordinatea[i] = (UNIT_TYPE)p[i];
308 template < prototype_number NUMBER1 >
309 constexpr sequence_type(
const sequence_t_type < NUMBER1, 4 > & sequence)
312 this->m_coordinatea[0] = (UNIT_TYPE) sequence.m_coordinatea[0];
313 this->m_coordinatea[1] = (UNIT_TYPE) sequence.m_coordinatea[1];
314 this->m_coordinatea[2] = (UNIT_TYPE) sequence.m_coordinatea[2];
315 this->m_coordinatea[3] = (UNIT_TYPE) sequence.m_coordinatea[3];
319 template<prototype_number NUMBER0, prototype_number NUMBER1>
320 constexpr sequence_type(NUMBER0 coordinate0, NUMBER1 coordinate1)
323 this->m_coordinatea[0] = (UNIT_TYPE)coordinate0;
324 this->m_coordinatea[1] = (UNIT_TYPE)coordinate1;
328 template<prototype_number NUMBER0, prototype_number NUMBER1, prototype_number NUMBER2>
329 constexpr sequence_type(NUMBER0 coordinate0, NUMBER1 coordinate1, NUMBER2 coordinate2)
332 this->m_coordinatea[0] = (UNIT_TYPE)coordinate0;
333 this->m_coordinatea[1] = (UNIT_TYPE)coordinate1;
334 this->m_coordinatea[2] = (UNIT_TYPE)coordinate2;
337 template<prototype_number NUMBER0, prototype_number NUMBER1, prototype_number NUMBER2, prototype_number NUMBER3>
338 constexpr sequence_type(NUMBER0 coordinate0, NUMBER1 coordinate1, NUMBER2 coordinate2, NUMBER3 coordinate3)
341 this->m_coordinatea[0] = (UNIT_TYPE)coordinate0;
342 this->m_coordinatea[1] = (UNIT_TYPE)coordinate1;
343 this->m_coordinatea[2] = (UNIT_TYPE)coordinate2;
344 this->m_coordinatea[3] = (UNIT_TYPE)coordinate3;
347 template<prototype_number NUMBER0, prototype_number NUMBER3>
348 constexpr sequence_type(
const sequence_type<NUMBER0, 3> &seq3, NUMBER3 coordinate3)
351 this->m_coordinatea[0] = (UNIT_TYPE)seq3[0];
352 this->m_coordinatea[1] = (UNIT_TYPE)seq3[1];
353 this->m_coordinatea[2] = (UNIT_TYPE)seq3[2];
354 this->m_coordinatea[3] = (UNIT_TYPE) coordinate3;
357 template<prototype_number NUMBER0, prototype_number NUMBER1>
358 constexpr sequence_type(NUMBER0 coordinate0,
const sequence_type<NUMBER1, 3> &seq3)
361 this->m_coordinatea[0] = (UNIT_TYPE)coordinate0;
362 this->m_coordinatea[1] = (UNIT_TYPE)seq3[0];
363 this->m_coordinatea[2] = (UNIT_TYPE)seq3[1];
364 this->m_coordinatea[3] = (UNIT_TYPE)seq3[2];
367 constexpr ::collection::count get_size()
const {
return SIZE; }
368 constexpr ::collection::count get_count()
const {
return this->get_size(); }
373 void set_null() { set_all(0); }
376 sequence_type &null()
384 static sequence_type Null() {
return {}; }
386 constexpr COORDINATE & set_coordinate(::collection::index i, COORDINATE coordinate)
389 return this->m_coordinatea[i] = coordinate;
394 constexpr COORDINATE coordinate(::collection::index i)
const
397 return this->m_coordinatea[i];
402 constexpr COORDINATE & coordinate(::collection::index i)
405 return this->m_coordinatea[i];
410 void set_all(COORDINATE coordinate)
413 for (::collection::count i = 0; i < SIZE; ++i)
416 this->m_coordinatea[i] = coordinate;
422 bool is_all(COORDINATE coordinate)
const
425 for (::collection::count i = 0; i < SIZE; ++i)
428 if(this->m_coordinatea[i] != coordinate)
444 template < ::collection::count S = SIZE, std::enable_if_t<S <= 2, ::i32> = 0 >
445 inline
void add2(const sequence_type & a)
450 template < ::collection::count S = SIZE, std::enable_if_t<S <= 2, ::i32> = 0 >
451 inline
void sub2(const sequence_type & a)
456 template < ::collection::count S = SIZE, std::enable_if_t<S <= 2, ::i32> = 0 >
457 inline
void mul2(UNIT_TYPE n)
462 template < ::collection::count S = SIZE, std::enable_if_t<S <= 2, ::i32> = 0 >
463 inline
void set2(UNIT_TYPE a, UNIT_TYPE b)
469 template < ::collection::count S = SIZE, std::enable_if_t<S <= 2, ::i32> = 0 >
470 static inline
void mix2(const sequence_type &a, const sequence_type &b, UNIT_TYPE t, sequence_type &c)
472 c.x = a.x*((UNIT_TYPE)1.0 - t) + b.x*t;
473 c.y = a.y*((UNIT_TYPE)1.0 - t) + b.y*t;
477 template < ::collection::count S = SIZE, std::enable_if_t<S <= 3, ::i32> = 0 >
478 inline
void add3(const sequence_type & a)
484 template < ::collection::count S = SIZE, std::enable_if_t<S <= 3, ::i32> = 0 >
485 inline
void sub3(const sequence_type & a)
491 template < ::collection::count S = SIZE, std::enable_if_t<S <= 3, ::i32> = 0 >
492 inline
void mul3(UNIT_TYPE n)
498 template < ::collection::count S = SIZE, std::enable_if_t<S <= 3, ::i32> = 0 >
499 inline
void set3(UNIT_TYPE a, UNIT_TYPE b, UNIT_TYPE c)
506 template < ::collection::count S = SIZE, std::enable_if_t<S <= 3, ::i32> = 0 >
507 static inline
void mix3(const sequence_type &a, const sequence_type &b, UNIT_TYPE t, sequence_type &c)
509 c.x = a.x*((UNIT_TYPE)1.0 - t) + b.x*t;
510 c.y = a.y*((UNIT_TYPE)1.0 - t) + b.y*t;
511 c.z = a.z*((UNIT_TYPE)1.0 - t) + b.z*t;
515 template < ::collection::count S = SIZE, std::enable_if_t<S <= 4, ::i32> = 0 >
516 inline
void add4(const sequence_type & q)
523 template < ::collection::count S = SIZE, std::enable_if_t<S <= 4, ::i32> = 0 >
524 inline
void sub4(const sequence_type & q)
531 template < ::collection::count S = SIZE, std::enable_if_t<S <= 4, ::i32> = 0 >
532 inline
void mul4(UNIT_TYPE n)
539 template < ::collection::count S = SIZE, std::enable_if_t<S <= 4, ::i32> = 0 >
540 inline
void set4(UNIT_TYPE a, UNIT_TYPE b, UNIT_TYPE c, UNIT_TYPE d)
548 template < ::collection::count S = SIZE, std::enable_if_t<S <= 4, ::i32> = 0 >
549 static inline
void mix4(const sequence_type &a, const sequence_type &b, UNIT_TYPE t, sequence_type &c)
551 c.x = a.x*((UNIT_TYPE)1.0 - t) + b.x*t;
552 c.y = a.y*((UNIT_TYPE)1.0 - t) + b.y*t;
553 c.w = a.z*((UNIT_TYPE)1.0 - t) + b.z*t;
554 c.z = a.w*((UNIT_TYPE)1.0 - t) + b.w*t;
558 sequence_type operator-() const
560 sequence_type result;
561 for (::collection::count i = 0; i < SIZE; ++i)
562 result[i] = -this->m_coordinatea[i];
567 sequence_type operator +(const sequence_type& b) const
569 sequence_type result;
570 for (::collection::count i = 0; i < SIZE; ++i)
571 result[i] = this->m_coordinatea[i] + b.m_coordinatea[i];
575 sequence_type& operator +=(const sequence_type& a) {
576 for (::collection::count i = 0; i < SIZE; ++i)
577 this->m_coordinatea[i] += a.m_coordinatea[i];
581 friend sequence_type operator-(const sequence_type& a, const sequence_type& b) {
582 sequence_type result;
583 for (::collection::count i = 0; i < SIZE; ++i)
584 result[i] = a.m_coordinatea[i] - b.m_coordinatea[i];
588 sequence_type& operator-=(const sequence_type& a) {
589 for (::collection::count i = 0; i < SIZE; ++i)
590 this->m_coordinatea[i] -= a.m_coordinatea[i];
594 sequence_type operator *(const sequence_type& b) const {
595 const sequence_type &a = *this;
596 sequence_type result;
597 for (::collection::count i = 0; i < SIZE; ++i)
598 result[i] = a.m_coordinatea[i] * b.m_coordinatea[i];
602 template<prototype_
floating FLOATING1>
604 requires(t_iSize == 3 && ::std::is_same_v<FLOATING1, NUMBER>);
606 template<prototype_
floating FLOATING1>
608 requires(t_iSize == 4 && ::std::is_same_v<FLOATING1, NUMBER>);
610 template < prototype_number NUMBER1 >
611 sequence_type < largest_number < UNIT_TYPE, NUMBER1 >, SIZE > operator *(NUMBER1 n)
const
613 sequence_type < largest_number < UNIT_TYPE, NUMBER1 >, SIZE > result;
614 for (::collection::count i = 0; i < SIZE; ++i)
615 result[i] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[i] * n);
621 for (::collection::count i = 0; i < SIZE; ++i)
622 this->m_coordinatea[i] *= a.m_coordinatea[i];
629 for (::collection::count i = 0; i < SIZE; ++i)
630 result[i] = a.m_coordinatea[i] / b.m_coordinatea[i];
635 template < prototype_number NUMBER1 >
636 sequence_type < largest_number < UNIT_TYPE, NUMBER1 >, SIZE > operator /(NUMBER1 n)
const
638 sequence_type < largest_number < UNIT_TYPE, NUMBER1 >, SIZE > result;
639 for (::collection::count i = 0; i < SIZE; ++i)
640 result[i] = (largest_number < UNIT_TYPE, NUMBER1 >) (this->m_coordinatea[i] / n);
646 for (::collection::count i = 0; i < SIZE; ++i)
647 this->m_coordinatea[i] /= a.m_coordinatea[i];
651 template < prototype_number NUMBER1 >
654 for (::collection::count i = 0; i < SIZE; ++i)
655 this->m_coordinatea[i] = (UNIT_TYPE) ((largest_number < UNIT_TYPE, NUMBER1 >)this->m_coordinatea[i] / (largest_number < UNIT_TYPE, NUMBER1 >)n);
660 for (::collection::count i = 0; i < SIZE; ++i) {
661 if (this->m_coordinatea[i] != a.m_coordinatea[i])
670 template <
typename PREDICATE >
671 bool is_every(PREDICATE predicate)
const
674 for (::collection::count i = 0; i < SIZE; ++i)
677 if (!predicate(this->m_coordinatea[i]))
691 bool is_empty()
const
694 return is_every([](
auto coordinate) {
return coordinate == COORDINATE{}; });
707 bool is_all_set()
const
710 return is_every([](
auto coordinate) {
return coordinate != COORDINATE{}; });
715 bool is_all_positive()
const
718 return is_every([](
auto coordinate) {
return coordinate > COORDINATE{}; });
723 template <
typename PREDICATE >
729 for (::collection::count i = 0; i < SIZE; ++i)
732 if (predicate(this->m_coordinatea[i]))
735 vector[i] = this->m_coordinatea[i];
741 vector[i] = vectorOther.m_coordinatea[i];
755 return prefer_self_coordinate_if(vectorOther, [](
auto coordinate) {
return coordinate != 0; });
763 return prefer_self_coordinate_if(vectorOther, [](
auto coordinate) {
return coordinate > COORDINATE{}; });
768 template <
typename PREDICATE,
typename SOURCE_PREDICATE >
769 sequence_type pred_prefer_self_coordinate_if(PREDICATE predicate, SOURCE_PREDICATE sourcepredicate)
const
772 if (is_every(predicate))
779 auto vectorOther = sourcepredicate();
781 return prefer_self_coordinate_if(vectorOther, predicate);
786 template <
typename SOURCE_PREDICATE >
787 sequence_type pred_prefer_self_coordinate_if_set(SOURCE_PREDICATE sourcepredicate)
const
790 return pred_prefer_self_coordinate_if([](
auto coordinate) {
return coordinate != COORDINATE{}; }, sourcepredicate);
795 template <
typename SOURCE_PREDICATE >
796 sequence_type pred_prefer_self_coordinate_if_positive(SOURCE_PREDICATE sourcepredicate)
const
799 return pred_prefer_self_coordinate_if([](
auto coordinate) {
return coordinate > COORDINATE{}; }, sourcepredicate);
805 constexpr bool operator!=(
const sequence_type& a)
const {
return !operator==(a); }
807 constexpr const COORDINATE& operator[](::collection::count i)
const {
return this->m_coordinatea[i]; }
809 constexpr COORDINATE& operator[](::collection::count i) {
return this->m_coordinatea[i]; }
832 template <::collection::count S = SIZE, std::enable_if_t<(S == 2), ::i32> = 0>
833 COORDINATE dot_with_left_perpendicular_of(
const sequence_type & b)
836 return (this->y * b.x) - (this->x * b.y);
841 template <::collection::count S = SIZE, std::enable_if_t<(S == 2), ::i32> = 0>
845 return ::std::atan2(this->dot_with_left_perpendicular_of(b), this->dotted(b));
855 for (::collection::count i = 0; i < SIZE; ++i)
858 result.m_coordinatea[i] = ::maximum(this->m_coordinatea[i], vector.m_coordinatea[i]);
871 for (::collection::count i = 0; i < SIZE; ++i)
874 result.m_coordinatea[i] = ::minimum(this->m_coordinatea[i], vector.m_coordinatea[i]);
885 if (
this != &sequence)
888 for (::collection::count i = 0; i < SIZE; ++i)
891 this->m_coordinatea[i] = sequence.m_coordinatea[i];
901 UNIT_TYPE minimum()
const
904 UNIT_TYPE nMinimum = this->m_coordinatea[0];
906 for (::collection::count i = 1; i < SIZE; ++i)
909 nMinimum = ::minimum(nMinimum, this->m_coordinatea[i]);
918 UNIT_TYPE maximum()
const
921 UNIT_TYPE nMaximum = this->m_coordinatea[0];
923 for (::collection::count i = 1; i < SIZE; ++i)
926 nMaximum = ::maximum(nMaximum, this->m_coordinatea[i]);
940 COORDINATE result = this->m_coordinatea[0] * vector.m_coordinatea[0];
942 for (::collection::count i = 1; i < SIZE; ++i)
945 result += this->m_coordinatea[i] * vector.m_coordinatea[i];
958 return *
this / modulus();
963 const UNIT_TYPE & get_dimension(enum_orientation eorientation)
const
966 return this->m_coordinatea[eorientation];
970 UNIT_TYPE & get_dimension(enum_orientation eorientation)
973 return this->m_coordinatea[eorientation];
978 template < ::collection::count S = SIZE, std::enable_if_t<S == 2, ::i32> = 0 >
979 const UNIT_TYPE & get_normal_dimension(enum_orientation eorientation)
const
982 return this->m_coordinatea[orthogonal2_index_of(eorientation)];
987 template < ::collection::count S = SIZE, std::enable_if_t<S == 2, ::i32> = 0 >
988 UNIT_TYPE & get_normal_dimension(enum_orientation eorientation)
991 return this->m_coordinatea[orthogonal2_index_of(eorientation)];
996 inline UNIT_TYPE & set_dimension(enum_orientation eorientation, UNIT_TYPE l)
noexcept
999 return this->m_coordinatea[eorientation] = l;
1004 inline UNIT_TYPE & set_orthogonal_dimension(enum_orientation eorientation, UNIT_TYPE l)
noexcept
1007 return this->m_coordinatea[orthogonal2_index_of(eorientation)] = l;
1014 const auto &a = *
this;
1015 return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x};
1018 inline NUMBER squared_modulus() const
1026 inline NUMBER squared_modulus() const
1035 inline NUMBER squared_modulus() const
1045 inline NUMBER modulus()
const
1047 return ::std::sqrt(squared_modulus());
1051 inline NUMBER length()
const
1062 return (b - *
this).modulus();
1070 auto modulus = this->modulus();
1075 return *
this /= modulus;
1093 return sequence.normalize();
1098 template<prototype_
floating FLOATING>
1102 return *
this * ((FLOATING)1 - t) + b * t;
1111 return this->crossed(sequence3WorldUp).normalized();
1120 return this->crossed(front).normalized();
1128 for (::collection::count i = 0; i < SIZE; ++i)
1129 result[i] = ::std::cos(this->m_coordinatea[i]);
1137 for (::collection::count i = 0; i < SIZE; ++i)
1138 result[i] = ::std::sin(this->m_coordinatea[i]);
1143 auto as_translation_matrix() const
1146 auto as_scaling_matrix() const