35 template <
class RType>
40 constexpr BasicRef(RType &x_in, RType &y_in) :
x{x_in},
y{y_in} { }
74 return { left.
x + right.
x, left.
y + right.
y };
81 return { left.
x + right.
x, left.
y + right.
y };
88 return { left.
x - right.
x, left.
y - right.
y };
95 return { left.
x - right.
x, left.
y - right.
y };
102 return { left.
x * right.
x, left.
y * right.
y };
109 return { left.
x * right.
x, left.
y * right.
y };
116 return { left.
x * scalar, left.
y * scalar };
123 return { scalar * right.
x, scalar * right.
y };
130 return { left.
x / right.
x, left.
y / right.
y };
137 return { left.
x / right.
x, left.
y / right.
y };
144 return { left.
x / scalar, left.
y / scalar };
148 constexpr operator std::tuple<RType, RType>()
const {
return std::make_tuple(
x,
y ); }
154 template <
class U, std::
floating_po
int OT =
float>
158 OT tolerance = OT{0.0002})
164 template <
class U, std::
floating_po
int OT =
float>
168 OT tolerance = OT{0.0002})
176 return input.
x + input.
y;
183 return (left.
x * right.
x) + (left.
y * right.
y);
190 return (left.
x * right.
x) + (left.
y * right.
y);
197 return dot(left, right) / (left.magnitude() * right.magnitude());
204 return dot(left, right) / (left.magnitude() * right.
magnitude());
211 return (left.
x * right.
y) - (left.
y * right.
x);
218 return (left.
x * right.
y) - (left.
y * right.
x);
228 return { std::abs(input.
x), std::abs(input.
y) };
235 return { std::modf(input.
x, &dummy), std::modf(input.
y, &dummy) };
248 float percentage_zero_to_one)
250 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
257 float percentage_zero_to_one)
259 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
266 float percentage_zero_to_one)
268 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
275 float percentage_zero_to_one)
277 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
282 return std::format(
"[x: {:.6}, y: {:.6}]", input.
x, input.
y);
285 template <
class U, std::
floating_po
int OT =
float>
289 OT tolerance = OT{0.0002})
293 auto diff{ near_to - input };
295 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
306 template <
class U, std::
floating_po
int OT =
float>
310 OT tolerance = OT{0.0002})
314 auto diff{ near_to - input };
316 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
327 template <
class U, std::
floating_po
int OT =
float>
331 OT tolerance = OT{0.0002})
335 auto diff{ near_to - input };
337 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
348 template <
class U, std::
floating_po
int OT =
float>
352 OT tolerance = OT{0.0002})
356 auto diff{ near_to - input };
358 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
369 template <
class U, std::
floating_po
int OT =
float>
373 OT tolerance = OT{0.0002})
378 template <
class U, std::
floating_po
int OT =
float>
382 OT tolerance = OT{0.0002})
387 template <
class U, std::
floating_po
int OT =
float>
391 OT tolerance = OT{0.0002})
396 template <
class U, std::
floating_po
int OT =
float>
400 OT tolerance = OT{0.0002})
405 template <std::
floating_po
int OT =
float>
428 x{ std::get<0>( t ) },
429 y{ std::get<1>( t ) }
449 constexpr operator std::tuple<Type, Type>()
const {
return std::make_tuple(
x,
y ); }
471 return {
x / n,
y / n };
477 bool isNaN()
const {
return std::isnan(
x) || std::isnan(
y); }
478 bool isInf()
const {
return std::isinf(
x) || std::isinf(
y); }
541 template <
class U, std::
floating_po
int OT =
float>
545 OT tolerance = OT{0.0002})
561 template <
class U, std::
floating_po
int OT =
float>
565 OT tolerance = OT{0.0002})
588 return { left.
x + right.
x, left.
y + right.
y };
595 return { left.
x + right.
x, left.
y + right.
y };
602 return { left.
x - right.
x, left.
y - right.
y };
609 return { left.
x - right.
x, left.
y - right.
y };
616 return { left.
x * right.
x, left.
y * right.
y };
623 return { left.
x * right.
x, left.
y * right.
y };
630 return { left.
x * scalar, left.
y * scalar };
637 return { scalar * right.
x, scalar * right.
y };
644 return { left.
x / right.
x, left.
y / right.
y };
651 return { left.
x / right.
x, left.
y / right.
y };
656 return { left.
x / scalar, left.
y / scalar };
673 return input.
x + input.
y;
691 return (left.
x * right.
x) + (left.
y * right.
y);
709 return (left.
x * right.
x) + (left.
y * right.
y);
745 return dot(left, right) / (left.
magnitude() * right.magnitude());
775 return (left.
x * right.
y) - (left.
y * right.
x);
794 return (left.
x * right.
y) - (left.
y * right.
x);
805 return { std::abs(input.
x), std::abs(input.
y) };
816 return { std::modf(input.
x), std::modf(input.
y) };
829 float percentage_zero_to_one)
831 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
838 float percentage_zero_to_one)
840 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
847 float percentage_zero_to_one)
849 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
856 float percentage_zero_to_one)
858 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
863 return std::format(
"[x: {:.6}, y: {:.6}]", input.
x, input.
y);
884 template <
class U, std::
floating_po
int OT =
float>
888 OT tolerance = OT{0.0002})
892 auto diff{ near_to - input };
894 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
913 template <
class U, std::
floating_po
int OT =
float>
917 OT tolerance = OT{0.0002})
921 auto diff{ near_to - input };
923 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
942 template <
class U, std::
floating_po
int OT =
float>
946 OT tolerance = OT{0.0002})
950 auto diff{ near_to - input };
952 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
971 template <
class U, std::
floating_po
int OT =
float>
975 OT tolerance = OT{0.0002})
979 auto diff{ near_to - input };
981 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
1011 template <
class U, std::
floating_po
int OT =
float>
1015 OT tolerance = OT{0.0002})
1028 template <
class U, std::
floating_po
int OT =
float>
1032 OT tolerance = OT{0.0002})
1045 template <
class U, std::
floating_po
int OT =
float>
1049 OT tolerance = OT{0.0002})
1062 template <
class U, std::
floating_po
int OT =
float>
1066 OT tolerance = OT{0.0002})
1078 template <std::
floating_po
int OT =
float>
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)
constexpr value_type normSquared() const
friend constexpr bool approximately_equal_to(BasicRef value_to_test, const BasicVector2D< U > &value_it_should_be, OT tolerance=OT{0.0002})
constexpr BasicVector2D xx()
friend std::string format(BasicRef input)
friend constexpr bool approximately_equal_to(BasicRef value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(BasicRef input, BasicRef near_to, OT tolerance=OT{0.0002})
friend constexpr Type cross(const BasicVector2D &left, const BasicVector2D< U > &right)
friend std::string format(const BasicVector2D &input)
friend constexpr Type accumulate(const BasicVector2D< Type > &input)
friend void CHECK_IF_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector2D()=default
constexpr BasicVector2D xy() &&
friend constexpr BasicVector2D< RType > lerp(BasicRef input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector2D< Type > saturate(const BasicVector2D &input, const Type lower_bound, Type upper_bound)
constexpr value_type magnitude() const
constexpr BasicRef & operator=(BasicRef input)
static constexpr BasicVector2D< Type > unit_y()
friend constexpr BasicVector2D< RType > mix(BasicRef input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector2D< RType > saturate(BasicRef input, RType lower_bound, RType upper_bound)
friend constexpr BasicVector2D< RType > lerp(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector2D(const Type &x_in, const Type &y_in=0)
constexpr BasicRef(RType &x_in, RType &y_in)
friend constexpr RType dot(BasicRef left, const BasicVector2D< U > &right)
friend constexpr RType dot_normalized(BasicRef left, const BasicVector2D< U > &right)
friend bool check_if_equal(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
static constexpr BasicVector2D< Type > zero()
friend void CHECK_IF_ZERO(BasicRef input, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< RType > abs(BasicRef input)
constexpr value_type norm() const
friend constexpr BasicVector2D< Type > normalized(const BasicVector2D &input)
constexpr BasicRef(const BasicVector2D< RType > &other)
constexpr BasicRef(const BasicRef &)=default
friend constexpr BasicVector2D< RType > operator/(BasicRef left, BasicRef< U > right)
constexpr BasicVector2D yy()
constexpr BasicVector2D yy() const
friend constexpr BasicVector2D< RType > operator-(BasicRef left, BasicRef< U > right)
constexpr value_type magnitudeSquared() const
RType value_type
The underlying implementation type.
BasicRef< const Type > ConstRef
constexpr ConstRef xy() const &
constexpr BasicVector2D< Type > & operator=(const BasicVector2D &other)=default
friend constexpr Type dot(const BasicVector2D &left, BasicRef< U > right)
friend constexpr BasicVector2D< Type > abs(const BasicVector2D &input)
friend constexpr Type cross(const BasicVector2D< Type > &left, BasicRef< U > right)
friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test, const BasicVector2D< U > &value_it_should_be, OT tolerance=OT{0.0002})
constexpr BasicVector2D yx() &&
friend bool check_if_equal(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< Type > mix(const BasicVector2D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
constexpr ConstRef yx() const &
friend constexpr RType dot_normalized(BasicRef left, BasicRef< U > right)
friend constexpr BasicVector2D< Type > lerp(const BasicVector2D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend void CHECK_IF_NOT_EQUAL(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr bool approximately_equal_to(const BasicVector2D &value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< RType > fract(BasicRef input)
static constexpr BasicVector2D< Type > unit_x()
friend constexpr BasicVector2D< RType > normalized(BasicRef input)
friend constexpr BasicVector2D< RType > mix(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector2D< Type > fract(const BasicVector2D &input)
friend constexpr RType dot(BasicRef left, BasicRef< U > right)
friend constexpr Type dot(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr Type dot_normalized(const BasicVector2D &left, BasicRef< U > right)
friend constexpr RType cross(BasicRef left, const BasicVector2D< U > &right)
constexpr BasicVector2D< Type > normalized() const
friend constexpr Type dot_normalized(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr bool operator==(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr bool operator==(BasicRef left, BasicRef< U > right)
friend bool check_if_not_equal(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< RType > operator+(BasicRef left, BasicRef< U > right)
friend constexpr BasicVector2D< Type > lerp(const BasicVector2D &input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector2D(const std::tuple< Type, Type > &t)
Type value_type
The underlying implementation type.
friend constexpr RType cross(BasicRef left, BasicRef< U > right)
constexpr BasicVector2D xx() const
friend constexpr BasicVector2D< Type > mix(const BasicVector2D &input_lower_bound, const BasicVector2D< U > &input_upper_bound, float percentage_zero_to_one)
friend void CHECK_IF_EQUAL(BasicRef input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr RType accumulate(BasicRef input)
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})
friend bool check_if_not_equal(const BasicVector2D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend bool check_if_equal(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(const BasicVector2D &input, const BasicVector2D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector2D< Type > operator-(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr BasicVector2D< Type > operator+(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr BasicVector2D< Type > operator*(const BasicVector2D &left, const BasicVector2D< U > &right)
friend constexpr BasicVector2D< Type > operator/(const BasicVector2D &left, const BasicVector2D< U > &right)
constexpr const Type & saturate(const Type &value, const Type &lower_bound, const Type &upper_bound)