MathLib
Loading...
Searching...
No Matches
Vector2D.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Math/Concepts.hpp>
5
13namespace Math
14{
15
20template <class Type>
22{
26 using value_type = Type;
28
35 template <class RType>
36 struct BasicRef
37 {
38 using value_type = RType;
39
40 constexpr BasicRef(RType &x_in, RType &y_in) : x{x_in}, y{y_in} { }
41 constexpr BasicRef(const BasicRef &) = default;
42 constexpr BasicRef(const BasicVector2D<RType> &other) : x{other.x}, y{other.y} { }
43
44 constexpr BasicRef &operator =(BasicRef input)
45 {
46 x = input.x;
47 y = input.y;
48 return *this;
49 }
50
51 constexpr BasicRef &operator =(const BasicVector2D<RType> &input)
52 {
53 x = input.x;
54 y = input.y;
55 return *this;
56 }
57
58 friend constexpr bool operator ==(BasicRef left, BasicRef<U> right)
59 {
60 return approximately_equal_to( left, right );
61 }
62
63 template <class U>
65 friend constexpr bool operator ==(BasicRef left, const BasicVector2D<U> &right)
66 {
67 return approximately_equal_to( left, right );
68 }
69
70 template <class U>
73 {
74 return { left.x + right.x, left.y + right.y };
75 }
76
77 template <class U>
79 friend constexpr BasicVector2D<RType> operator +(BasicRef left, const BasicVector2D<U> &right)
80 {
81 return { left.x + right.x, left.y + right.y };
82 }
83
84 template <class U>
87 {
88 return { left.x - right.x, left.y - right.y };
89 }
90
91 template <class U>
93 friend constexpr BasicVector2D<RType> operator -(BasicRef left, const BasicVector2D<U> &right)
94 {
95 return { left.x - right.x, left.y - right.y };
96 }
97
98 template <class U>
101 {
102 return { left.x * right.x, left.y * right.y };
103 }
104
105 template <class U>
107 friend constexpr BasicVector2D<RType> operator *(BasicRef left, const BasicVector2D<U> &right)
108 {
109 return { left.x * right.x, left.y * right.y };
110 }
111
112 template <class U>
114 friend constexpr BasicVector2D<RType> operator *(BasicRef left, const U &scalar)
115 {
116 return { left.x * scalar, left.y * scalar };
117 }
118
119 template <class U>
121 friend constexpr BasicVector2D<RType> operator *(const U &scalar, BasicRef right)
122 {
123 return { scalar * right.x, scalar * right.y };
124 }
125
126 template <class U>
129 {
130 return { left.x / right.x, left.y / right.y };
131 }
132
133 template <class U>
135 friend constexpr BasicVector2D<RType> operator /(BasicRef left, const BasicVector2D<U> &right)
136 {
137 return { left.x / right.x, left.y / right.y };
138 }
139
140 template <class U>
142 friend constexpr BasicVector2D<RType> operator /(BasicRef left, U scalar)
143 {
144 return { left.x / scalar, left.y / scalar };
145 }
146 constexpr operator BasicVector2D<RType>() const { return { x, y }; }
147
148 constexpr operator std::tuple<RType, RType>() const { return std::make_tuple( x, y ); }
149
150 RType &x;
151 RType &y;
152
153
154 template <class U, std::floating_point OT = float>
156 friend constexpr bool approximately_equal_to(BasicRef value_to_test,
157 BasicRef<U> value_it_should_be,
158 OT tolerance = OT{0.0002})
159 {
160 return approximately_equal_to(value_to_test.x, value_it_should_be.x, tolerance) &&
161 approximately_equal_to(value_to_test.y, value_it_should_be.y, tolerance);
162 }
163
164 template <class U, std::floating_point OT = float>
166 friend constexpr bool approximately_equal_to( BasicRef value_to_test,
167 const BasicVector2D<U> &value_it_should_be,
168 OT tolerance = OT{0.0002})
169 {
170 return approximately_equal_to(value_to_test.x, value_it_should_be.x, tolerance) &&
171 approximately_equal_to(value_to_test.y, value_it_should_be.y, tolerance);
172 }
173
174 friend constexpr RType accumulate(BasicRef input)
175 {
176 return input.x + input.y;
177 }
178
179 template <class U>
181 friend constexpr RType dot(BasicRef left, BasicRef<U> right)
182 {
183 return (left.x * right.x) + (left.y * right.y);
184 }
185
186 template <class U>
188 friend constexpr RType dot(BasicRef left, const BasicVector2D<U> &right)
189 {
190 return (left.x * right.x) + (left.y * right.y);
191 }
192
193 template <class U>
195 friend constexpr RType dot_normalized(BasicRef left, BasicRef<U> right)
196 {
197 return dot(left, right) / (left.magnitude() * right.magnitude());
198 }
199
200 template <class U>
202 friend constexpr RType dot_normalized(BasicRef left, const BasicVector2D<U> &right)
203 {
204 return dot(left, right) / (left.magnitude() * right.magnitude());
205 }
206
207 template <class U>
209 friend constexpr RType cross(BasicRef left, BasicRef<U> right)
210 {
211 return (left.x * right.y) - (left.y * right.x);
212 }
213
214 template <class U>
216 friend constexpr RType cross(BasicRef left, const BasicVector2D<U> &right)
217 {
218 return (left.x * right.y) - (left.y * right.x);
219 }
220
222 {
223 return BasicVector2D<RType>( input ).normalized();
224 }
225
226 friend constexpr BasicVector2D<RType> abs(BasicRef input)
227 {
228 return { std::abs(input.x), std::abs(input.y) };
229 }
230
231 friend constexpr BasicVector2D<RType> fract(BasicRef input)
232 {
233 Type dummy;
234
235 return { std::modf(input.x, &dummy), std::modf(input.y, &dummy) };
236 }
237
238 friend constexpr BasicVector2D<RType> saturate(BasicRef input, RType lower_bound, RType upper_bound)
239 {
240 return { Math::saturate(input.x, lower_bound, upper_bound),
241 Math::saturate(input.y, lower_bound, upper_bound) };
242 }
243
244 template <class U>
246 friend constexpr BasicVector2D<RType> lerp(BasicRef input_lower_bound,
247 BasicRef<U> input_upper_bound,
248 float percentage_zero_to_one)
249 {
250 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
251 }
252
253 template <class U>
255 friend constexpr BasicVector2D<RType> lerp( BasicRef input_lower_bound,
256 const BasicVector2D<U> &input_upper_bound,
257 float percentage_zero_to_one)
258 {
259 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
260 }
261
262 template <class U>
264 friend constexpr BasicVector2D<RType> mix(BasicRef input_lower_bound,
265 BasicRef<U> input_upper_bound,
266 float percentage_zero_to_one)
267 {
268 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
269 }
270
271 template <class U>
273 friend constexpr BasicVector2D<RType> mix( BasicRef input_lower_bound,
274 const BasicVector2D<U> &input_upper_bound,
275 float percentage_zero_to_one)
276 {
277 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
278 }
279
280 friend std::string format(BasicRef input)
281 {
282 return std::format("[x: {:.6}, y: {:.6}]", input.x, input.y);
283 }
284
285 template <class U, std::floating_point OT = float>
287 friend bool check_if_equal(BasicRef input,
288 BasicRef<U> near_to,
289 OT tolerance = OT{0.0002})
290 {
291 if (!approximately_equal_to(input, near_to, tolerance))
292 {
293 auto diff{ near_to - input };
294
295 std::cout << std::format("input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
296 format(input),
297 format(near_to),
298 tolerance,
299 format(near_to - input))
300 << std::endl;
301 return false;
302 }
303 return true;
304 }
305
306 template <class U, std::floating_point OT = float>
308 friend bool check_if_equal( BasicRef input,
309 const BasicVector2D<U> &near_to,
310 OT tolerance = OT{0.0002})
311 {
312 if (!approximately_equal_to(input, near_to, tolerance))
313 {
314 auto diff{ near_to - input };
315
316 std::cout << std::format("input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
317 format(input),
318 format(near_to),
319 tolerance,
320 format(near_to - input))
321 << std::endl;
322 return false;
323 }
324 return true;
325 }
326
327 template <class U, std::floating_point OT = float>
329 friend bool check_if_not_equal(BasicRef input,
330 BasicRef near_to,
331 OT tolerance = OT{0.0002})
332 {
333 if (approximately_equal_to(input, near_to, tolerance))
334 {
335 auto diff{ near_to - input };
336
337 std::cout << std::format("input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
338 format(input),
339 format(near_to),
340 tolerance,
341 format(near_to - input))
342 << std::endl;
343 return false;
344 }
345 return true;
346 }
347
348 template <class U, std::floating_point OT = float>
350 friend bool check_if_not_equal( BasicRef input,
351 const BasicVector2D<U> &near_to,
352 OT tolerance = OT{0.0002})
353 {
354 if (approximately_equal_to(input, near_to, tolerance))
355 {
356 auto diff{ near_to - input };
357
358 std::cout << std::format("input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
359 format(input),
360 format(near_to),
361 tolerance,
362 format(near_to - input))
363 << std::endl;
364 return false;
365 }
366 return true;
367 }
368
369 template <class U, std::floating_point OT = float>
371 friend void CHECK_IF_EQUAL(BasicRef input,
372 BasicRef<U> near_to,
373 OT tolerance = OT{0.0002})
374 {
375 assert( check_if_equal(input, near_to, tolerance) );
376 }
377
378 template <class U, std::floating_point OT = float>
380 friend void CHECK_IF_EQUAL( BasicRef input,
381 const BasicVector2D<U> &near_to,
382 OT tolerance = OT{0.0002})
383 {
384 assert( check_if_equal(input, near_to, tolerance) );
385 }
386
387 template <class U, std::floating_point OT = float>
389 friend void CHECK_IF_NOT_EQUAL(BasicRef input,
390 BasicRef<U> near_to,
391 OT tolerance = OT{0.0002})
392 {
393 assert( check_if_not_equal(input, near_to, tolerance) );
394 }
395
396 template <class U, std::floating_point OT = float>
398 friend void CHECK_IF_NOT_EQUAL( BasicRef input,
399 const BasicVector2D<U> &near_to,
400 OT tolerance = OT{0.0002})
401 {
402 assert( check_if_not_equal(input, near_to, tolerance) );
403 }
404
405 template <std::floating_point OT = float>
406 friend void CHECK_IF_ZERO(BasicRef input, OT tolerance = OT{0.0002})
407 {
408 assert( check_if_equal(input, BasicVector2D<RType>::zero(), tolerance));
409 }
410 };
411
414
419 constexpr BasicVector2D() = default;
420 constexpr BasicVector2D(const Type &x_in, const Type &y_in = 0)
421 :
422 x{x_in},
423 y{y_in}
424 {
425 }
426 constexpr BasicVector2D(const std::tuple<Type, Type> &t)
427 :
428 x{ std::get<0>( t ) },
429 y{ std::get<1>( t ) }
430 {
431 }
433
437 constexpr BasicVector2D<Type> &operator =(const BasicVector2D &other) = default;
439 {
440 x = other.x;
441 y = other.y;
442 return *this;
443 }
445
449 constexpr operator std::tuple<Type, Type>() const { return std::make_tuple( x, y ); }
451
455 constexpr static BasicVector2D<Type> unit_x() { return { Type{1}, Type{0} }; }
456 constexpr static BasicVector2D<Type> unit_y() { return { Type{0}, Type{1} }; }
457
458 constexpr static BasicVector2D<Type> zero() { return {}; }
460
461 constexpr value_type normSquared() const { return (x * x) + (y * y); }
462 constexpr value_type norm() const { return std::sqrt( normSquared() ); }
463
464 constexpr value_type magnitudeSquared() const { return normSquared(); }
465 constexpr value_type magnitude() const { return norm(); }
466
468 {
469 auto n = norm();
470
471 return { x / n, y / n };
472 }
473
477 bool isNaN() const { return std::isnan(x) || std::isnan(y); }
478 bool isInf() const { return std::isinf(x) || std::isinf(y); }
480
484 constexpr BasicVector2D xx() const { return { x, x }; }
485 constexpr BasicVector2D xx() { return { x, x }; }
486
487 constexpr BasicVector2D yy() const { return { y, y }; }
488 constexpr BasicVector2D yy() { return { y, y }; }
489
490 constexpr ConstRef xy() const & { return { x, y }; }
491 constexpr Ref xy() & { return { x, y }; }
492 constexpr BasicVector2D xy() && { return { x, y }; }
493
494 constexpr ConstRef yx() const & { return { y, x }; }
495 constexpr Ref yx() & { return { y, x }; }
496 constexpr BasicVector2D yx() && { return { y, x }; }
498
499
503 Type x{};
504 Type y{};
506
507private:
508
524 template <class U>
526 friend constexpr bool operator ==(const BasicVector2D &left, const BasicVector2D<U> &right)
527 {
528 return approximately_equal_to(left, right);
529 }
530
541 template <class U, std::floating_point OT = float>
543 friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test,
544 const BasicVector2D<U> &value_it_should_be,
545 OT tolerance = OT{0.0002})
546 {
547 return approximately_equal_to(value_to_test.x, value_it_should_be.x, tolerance) &&
548 approximately_equal_to(value_to_test.y, value_it_should_be.y, tolerance);
549 }
550
561 template <class U, std::floating_point OT = float>
563 friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test,
564 BasicRef<U> value_it_should_be,
565 OT tolerance = OT{0.0002})
566 {
567 return approximately_equal_to(value_to_test.x, value_it_should_be.x, tolerance) &&
568 approximately_equal_to(value_to_test.y, value_it_should_be.y, tolerance);
569 }
571
584 template <class U>
586 friend constexpr BasicVector2D<Type> operator +(const BasicVector2D &left, const BasicVector2D<U> &right)
587 {
588 return { left.x + right.x, left.y + right.y };
589 }
590
591 template <class U>
593 friend constexpr BasicVector2D<Type> operator +(const BasicVector2D &left, BasicRef<U> right)
594 {
595 return { left.x + right.x, left.y + right.y };
596 }
597
598 template <class U>
600 friend constexpr BasicVector2D<Type> operator -(const BasicVector2D &left, const BasicVector2D<U> &right)
601 {
602 return { left.x - right.x, left.y - right.y };
603 }
604
605 template <class U>
607 friend constexpr BasicVector2D<Type> operator -(const BasicVector2D &left, BasicRef<U> right)
608 {
609 return { left.x - right.x, left.y - right.y };
610 }
611
612 template <class U>
614 friend constexpr BasicVector2D<Type> operator *(const BasicVector2D &left, const BasicVector2D<U> &right)
615 {
616 return { left.x * right.x, left.y * right.y };
617 }
618
619 template <class U>
621 friend constexpr BasicVector2D<Type> operator *(const BasicVector2D &left, BasicRef<U> right)
622 {
623 return { left.x * right.x, left.y * right.y };
624 }
625
626 template <class U>
628 friend constexpr BasicVector2D<Type> operator *(const BasicVector2D &left, const U &scalar)
629 {
630 return { left.x * scalar, left.y * scalar };
631 }
632
633 template <class U>
635 friend constexpr BasicVector2D<Type> operator *(const U &scalar, const BasicVector2D<U> &right)
636 {
637 return { scalar * right.x, scalar * right.y };
638 }
639
640 template <class U>
642 friend constexpr BasicVector2D<Type> operator /(const BasicVector2D &left, const BasicVector2D<U> &right)
643 {
644 return { left.x / right.x, left.y / right.y };
645 }
646
647 template <class U>
649 friend constexpr BasicVector2D<Type> operator /(const BasicVector2D &left, BasicRef<U> right)
650 {
651 return { left.x / right.x, left.y / right.y };
652 }
653
654 friend constexpr BasicVector2D<Type> operator /(const BasicVector2D &left, const Type &scalar)
655 {
656 return { left.x / scalar, left.y / scalar };
657 }
660
671 friend constexpr Type accumulate(const BasicVector2D<Type> &input)
672 {
673 return input.x + input.y;
674 }
675
687 template <class U>
689 friend constexpr Type dot(const BasicVector2D &left, const BasicVector2D<U> &right)
690 {
691 return (left.x * right.x) + (left.y * right.y);
692 }
693
705 template <class U>
707 friend constexpr Type dot(const BasicVector2D &left, BasicRef<U> right)
708 {
709 return (left.x * right.x) + (left.y * right.y);
710 }
711
723 template <class U>
725 friend constexpr Type dot_normalized(const BasicVector2D &left, const BasicVector2D<U> &right)
726 {
727 return dot(left, right) / (left.magnitude() * right.magnitude());
728 }
729
741 template <class U>
743 friend constexpr Type dot_normalized(const BasicVector2D &left, BasicRef<U> right)
744 {
745 return dot(left, right) / (left.magnitude() * right.magnitude());
746 }
747
754 friend constexpr BasicVector2D<Type> normalized(const BasicVector2D &input)
755 {
756 return input.normalized();
757 }
758
771 template <class U>
773 friend constexpr Type cross(const BasicVector2D &left, const BasicVector2D<U> &right)
774 {
775 return (left.x * right.y) - (left.y * right.x);
776 }
777
790 template <class U>
792 friend constexpr Type cross(const BasicVector2D<Type> &left, BasicRef<U> right)
793 {
794 return (left.x * right.y) - (left.y * right.x);
795 }
796
803 friend constexpr BasicVector2D<Type> abs(const BasicVector2D &input)
804 {
805 return { std::abs(input.x), std::abs(input.y) };
806 }
807
814 friend constexpr BasicVector2D<Type> fract(const BasicVector2D &input)
815 {
816 return { std::modf(input.x), std::modf(input.y) };
817 }
818
819 friend constexpr BasicVector2D<Type> saturate(const BasicVector2D &input, const Type lower_bound, Type upper_bound)
820 {
821 return { Math::saturate(input.x, lower_bound, upper_bound),
822 Math::saturate(input.y, lower_bound, upper_bound) };
823 }
824
825 template <class U>
827 friend constexpr BasicVector2D<Type> lerp(const BasicVector2D &input_lower_bound,
828 const BasicVector2D<U> &input_upper_bound,
829 float percentage_zero_to_one)
830 {
831 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
832 }
833
834 template <class U>
836 friend constexpr BasicVector2D<Type> lerp(const BasicVector2D &input_lower_bound,
837 BasicRef<U> input_upper_bound,
838 float percentage_zero_to_one)
839 {
840 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
841 }
842
843 template <class U>
845 friend constexpr BasicVector2D<Type> mix(const BasicVector2D &input_lower_bound,
846 const BasicVector2D<U> &input_upper_bound,
847 float percentage_zero_to_one)
848 {
849 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
850 }
851
852 template <class U>
854 friend constexpr BasicVector2D<Type> mix(const BasicVector2D &input_lower_bound,
855 BasicRef<U> input_upper_bound,
856 float percentage_zero_to_one)
857 {
858 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
859 }
860
861 friend std::string format(const BasicVector2D &input)
862 {
863 return std::format("[x: {:.6}, y: {:.6}]", input.x, input.y);
864 }
866
884 template <class U, std::floating_point OT = float>
886 friend bool check_if_equal(const BasicVector2D &input,
887 const BasicVector2D<U> &near_to,
888 OT tolerance = OT{0.0002})
889 {
890 if (!approximately_equal_to(input, near_to, tolerance))
891 {
892 auto diff{ near_to - input };
893
894 std::cout << std::format("input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
895 format(input),
896 format(near_to),
897 tolerance,
898 format(near_to - input))
899 << std::endl;
900 return false;
901 }
902 return true;
903 }
904
913 template <class U, std::floating_point OT = float>
915 friend bool check_if_equal(const BasicVector2D &input,
916 BasicRef<U> near_to,
917 OT tolerance = OT{0.0002})
918 {
919 if (!approximately_equal_to(input, near_to, tolerance))
920 {
921 auto diff{ near_to - input };
922
923 std::cout << std::format("input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
924 format(input),
925 format(near_to),
926 tolerance,
927 format(near_to - input))
928 << std::endl;
929 return false;
930 }
931 return true;
932 }
933
942 template <class U, std::floating_point OT = float>
944 friend bool check_if_not_equal(const BasicVector2D &input,
945 const BasicVector2D<U> &near_to,
946 OT tolerance = OT{0.0002})
947 {
948 if (approximately_equal_to(input, near_to, tolerance))
949 {
950 auto diff{ near_to - input };
951
952 std::cout << std::format("input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
953 format(input),
954 format(near_to),
955 tolerance,
956 format(near_to - input))
957 << std::endl;
958 return false;
959 }
960 return true;
961 }
962
971 template <class U, std::floating_point OT = float>
973 friend bool check_if_not_equal(const BasicVector2D &input,
974 BasicRef<U> near_to,
975 OT tolerance = OT{0.0002})
976 {
977 if (approximately_equal_to(input, near_to, tolerance))
978 {
979 auto diff{ near_to - input };
980
981 std::cout << std::format("input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
982 format(input),
983 format(near_to),
984 tolerance,
985 format(near_to - input))
986 << std::endl;
987 return false;
988 }
989 return true;
990 }
993
1011 template <class U, std::floating_point OT = float>
1013 friend void CHECK_IF_EQUAL(const BasicVector2D &input,
1014 const BasicVector2D<U> &near_to,
1015 OT tolerance = OT{0.0002})
1016 {
1017 assert( check_if_equal(input, near_to, tolerance) );
1018 }
1019
1028 template <class U, std::floating_point OT = float>
1030 friend void CHECK_IF_EQUAL(const BasicVector2D &input,
1031 BasicRef<U> near_to,
1032 OT tolerance = OT{0.0002})
1033 {
1034 assert( check_if_equal(input, near_to, tolerance) );
1035 }
1036
1045 template <class U, std::floating_point OT = float>
1047 friend void CHECK_IF_NOT_EQUAL(const BasicVector2D &input,
1048 const BasicVector2D<U> &near_to,
1049 OT tolerance = OT{0.0002})
1050 {
1051 assert( check_if_not_equal(input, near_to, tolerance) );
1052 }
1053
1062 template <class U, std::floating_point OT = float>
1064 friend void CHECK_IF_NOT_EQUAL(const BasicVector2D &input,
1065 BasicRef<U> near_to,
1066 OT tolerance = OT{0.0002})
1067 {
1068 assert( check_if_not_equal(input, near_to, tolerance) );
1069 }
1070
1078 template <std::floating_point OT = float>
1079 friend void CHECK_IF_ZERO(const BasicVector2D &input, OT tolerance = OT{0.0002})
1080 {
1081 assert( check_if_equal(input, BasicVector2D<Type>::zero(), tolerance));
1082 }
1085};
1086
1103
1109
1110
1128
1129}
friend void CHECK_IF_EQUAL(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_EQUAL(const BasicVector2D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(const BasicVector2D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_ZERO(const BasicVector2D &input, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< RType > operator*(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:100
constexpr value_type normSquared() const
Definition Vector2D.hpp:461
friend constexpr bool approximately_equal_to(BasicRef value_to_test, const BasicVector2D< U > &value_it_should_be, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:166
bool isNaN() const
Definition Vector2D.hpp:477
constexpr BasicVector2D xx()
Definition Vector2D.hpp:485
friend std::string format(BasicRef input)
Definition Vector2D.hpp:280
friend constexpr bool approximately_equal_to(BasicRef value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:156
friend bool check_if_not_equal(BasicRef input, BasicRef near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:329
friend constexpr Type cross(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:773
friend std::string format(const BasicVector2D &input)
Definition Vector2D.hpp:861
friend constexpr Type accumulate(const BasicVector2D< Type > &input)
Definition Vector2D.hpp:671
friend void CHECK_IF_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:371
constexpr BasicVector2D()=default
constexpr BasicVector2D xy() &&
Definition Vector2D.hpp:492
friend constexpr BasicVector2D< RType > lerp(BasicRef input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:255
friend constexpr BasicVector2D< Type > saturate(const BasicVector2D &input, const Type lower_bound, Type upper_bound)
Definition Vector2D.hpp:819
constexpr value_type magnitude() const
Definition Vector2D.hpp:465
constexpr BasicRef & operator=(BasicRef input)
Definition Vector2D.hpp:44
static constexpr BasicVector2D< Type > unit_y()
Definition Vector2D.hpp:456
friend constexpr BasicVector2D< RType > mix(BasicRef input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:273
friend constexpr BasicVector2D< RType > saturate(BasicRef input, RType lower_bound, RType upper_bound)
Definition Vector2D.hpp:238
friend constexpr BasicVector2D< RType > lerp(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:246
constexpr BasicVector2D(const Type &x_in, const Type &y_in=0)
Definition Vector2D.hpp:420
constexpr BasicRef(RType &x_in, RType &y_in)
Definition Vector2D.hpp:40
friend constexpr RType dot(BasicRef left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:188
friend constexpr RType dot_normalized(BasicRef left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:202
friend bool check_if_equal(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:287
constexpr Ref yx() &
Definition Vector2D.hpp:495
static constexpr BasicVector2D< Type > zero()
Definition Vector2D.hpp:458
friend void CHECK_IF_ZERO(BasicRef input, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:406
friend constexpr BasicVector2D< RType > abs(BasicRef input)
Definition Vector2D.hpp:226
constexpr value_type norm() const
Definition Vector2D.hpp:462
friend constexpr BasicVector2D< Type > normalized(const BasicVector2D &input)
Definition Vector2D.hpp:754
constexpr BasicRef(const BasicVector2D< RType > &other)
Definition Vector2D.hpp:42
constexpr BasicRef(const BasicRef &)=default
friend constexpr BasicVector2D< RType > operator/(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:128
constexpr BasicVector2D yy()
Definition Vector2D.hpp:488
constexpr BasicVector2D yy() const
Definition Vector2D.hpp:487
friend constexpr BasicVector2D< RType > operator-(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:86
constexpr value_type magnitudeSquared() const
Definition Vector2D.hpp:464
RType value_type
The underlying implementation type.
Definition Vector2D.hpp:38
BasicRef< const Type > ConstRef
Definition Vector2D.hpp:413
constexpr ConstRef xy() const &
Definition Vector2D.hpp:490
constexpr BasicVector2D< Type > & operator=(const BasicVector2D &other)=default
friend constexpr Type dot(const BasicVector2D &left, BasicRef< U > right)
Definition Vector2D.hpp:707
friend constexpr BasicVector2D< Type > abs(const BasicVector2D &input)
Definition Vector2D.hpp:803
friend constexpr Type cross(const BasicVector2D< Type > &left, BasicRef< U > right)
Definition Vector2D.hpp:792
friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test, const BasicVector2D< U > &value_it_should_be, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:543
constexpr BasicVector2D yx() &&
Definition Vector2D.hpp:496
friend bool check_if_equal(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:308
friend constexpr BasicVector2D< Type > mix(const BasicVector2D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:854
constexpr ConstRef yx() const &
Definition Vector2D.hpp:494
friend constexpr RType dot_normalized(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:195
friend constexpr BasicVector2D< Type > lerp(const BasicVector2D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:836
friend void CHECK_IF_NOT_EQUAL(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:398
friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:563
friend void CHECK_IF_NOT_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:389
BasicRef< Type > Ref
Definition Vector2D.hpp:412
friend constexpr BasicVector2D< RType > fract(BasicRef input)
Definition Vector2D.hpp:231
static constexpr BasicVector2D< Type > unit_x()
Definition Vector2D.hpp:455
friend constexpr BasicVector2D< RType > normalized(BasicRef input)
Definition Vector2D.hpp:221
constexpr Ref xy() &
Definition Vector2D.hpp:491
friend constexpr BasicVector2D< RType > mix(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:264
friend constexpr BasicVector2D< Type > fract(const BasicVector2D &input)
Definition Vector2D.hpp:814
friend constexpr RType dot(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:181
friend constexpr Type dot(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:689
friend constexpr Type dot_normalized(const BasicVector2D &left, BasicRef< U > right)
Definition Vector2D.hpp:743
friend constexpr RType cross(BasicRef left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:216
constexpr BasicVector2D< Type > normalized() const
Definition Vector2D.hpp:467
friend constexpr Type dot_normalized(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:725
friend constexpr bool operator==(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:526
friend constexpr bool operator==(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:58
friend bool check_if_not_equal(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:350
friend constexpr BasicVector2D< RType > operator+(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:72
friend constexpr BasicVector2D< Type > lerp(const BasicVector2D &input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:827
constexpr BasicVector2D(const std::tuple< Type, Type > &t)
Definition Vector2D.hpp:426
Type value_type
The underlying implementation type.
Definition Vector2D.hpp:26
friend constexpr RType cross(BasicRef left, BasicRef< U > right)
Definition Vector2D.hpp:209
constexpr BasicVector2D xx() const
Definition Vector2D.hpp:484
friend constexpr BasicVector2D< Type > mix(const BasicVector2D &input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
Definition Vector2D.hpp:845
friend void CHECK_IF_EQUAL(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:380
friend constexpr RType accumulate(BasicRef input)
Definition Vector2D.hpp:174
bool isInf() const
Definition Vector2D.hpp:478
BasicVector2D< float >::Ref Vector2DfRef
BasicVector2D< long double >::Ref Vector2DlRef
BasicVector2D< double >::Ref Vector2DRef
BasicVector2D< double >::Ref Vector2DdRef
BasicVector2D< double >::ConstRef Vector2DConstRef
BasicVector2D< double >::ConstRef Vector2DdConstRef
BasicVector2D< long double >::ConstRef Vector2DlConstRef
BasicVector2D< float >::ConstRef Vector2DfConstRef
friend bool check_if_equal(const BasicVector2D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:915
friend bool check_if_not_equal(const BasicVector2D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:973
friend bool check_if_equal(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:886
friend bool check_if_not_equal(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
Definition Vector2D.hpp:944
friend constexpr BasicVector2D< Type > operator-(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:600
friend constexpr BasicVector2D< Type > operator+(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:586
friend constexpr BasicVector2D< Type > operator*(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:614
friend constexpr BasicVector2D< Type > operator/(const BasicVector2D &left, const BasicVector2D< U > &right)
Definition Vector2D.hpp:642
Definition Angle.hpp:16
constexpr const Type & saturate(const Type &value, const Type &lower_bound, const Type &upper_bound)
Definition Functions.hpp:94