38 template <
class RType>
47 constexpr BasicRef(RType &x_in, RType &y_in, RType &z_in, RType &w_in) :
x{x_in},
y{y_in},
z{z_in},
w{w_in} { }
71 constexpr operator std::tuple<RType, RType, RType, RType>()
const {
return std::make_tuple(
x,
y,
z,
w ); }
96 return { left.
x + right.
x,
106 return { left.
x + right.
x,
116 return { left.
x - right.
x,
126 return { left.
x - right.
x,
136 return { left.
x * right.
x,
146 return { left.
x * right.
x,
156 return { left.
x * scalar, left.
y * scalar, left.
z * scalar, left.
w * scalar };
163 return { scalar * right.
x, scalar * right.
y, scalar * right.
z, scalar * right.
w };
170 return { left.
x / right.
x,
180 return { left.
x / right.
x,
190 return { left.
x / scalar, left.
y / scalar, left.
z / scalar, left.
w / scalar };
193 template <
class U, std::
floating_po
int OT =
float>
197 OT tolerance = OT{0.0002})
205 template <
class U, std::
floating_po
int OT =
float>
209 OT tolerance = OT{0.0002})
219 return input.
x + input.
y + input.
z + input.
w;
226 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z) + (left.
w * right.
w);
233 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z) + (left.
w * right.
w);
240 return dot(left, right) / (left.magnitude() * right.magnitude());
247 return dot(left, right) / (left.magnitude() * right.
magnitude());
257 return { std::abs(input.
x), std::abs(input.
y), std::abs(input.
z), std::abs(input.
w) };
264 return { std::modf(input.
x, &dummy),
265 std::modf(input.
y, &dummy),
266 std::modf(input.
z, &dummy),
267 std::modf(input.
w, &dummy) };
282 float percentage_zero_to_one)
284 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
291 float percentage_zero_to_one)
293 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
300 float percentage_zero_to_one)
302 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
309 float percentage_zero_to_one)
311 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
316 return std::format(
"[x: {:.6}, y: {:.6}, z: {:.6}, w: {:.6}]", input.
x, input.
y, input.
z, input.
w);
319 template <
class U, std::
floating_po
int OT =
float>
323 OT tolerance = OT{0.0002})
327 auto diff{ near_to - input };
329 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
340 template <
class U, std::
floating_po
int OT =
float>
344 OT tolerance = OT{0.0002})
348 auto diff{ near_to - input };
350 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
361 template <
class U, std::
floating_po
int OT =
float>
365 OT tolerance = OT{0.0002})
369 auto diff{ near_to - input };
371 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
382 template <
class U, std::
floating_po
int OT =
float>
386 OT tolerance = OT{0.0002})
390 auto diff{ near_to - input };
392 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
403 template <
class U, std::
floating_po
int OT =
float>
407 OT tolerance = OT{0.0002})
412 template <
class U, std::
floating_po
int OT =
float>
416 OT tolerance = OT{0.0002})
421 template <std::
floating_po
int OT =
float>
435 constexpr BasicVector4D(
const Type &x_in,
const Type &y_in = 0,
const Type &z_in = 0,
const Type &w_in = 0)
486 constexpr operator std::tuple<Type, Type, Type, Type>()
const {
return std::make_tuple(
x,
y,
z ); }
510 return {
x / n,
y / n,
z / n,
w / n };
516 bool isNaN()
const {
return std::isnan(
x) || std::isnan(
y) || std::isnan(
z) || std::isnan(
w); }
517 bool isInf()
const {
return std::isinf(
x) || std::isinf(
y) || std::isinf(
z) || std::isinf(
w); }
627 template <
class U, std::
floating_po
int OT =
float>
631 OT tolerance = OT{0.0002})
647 template <
class U, std::
floating_po
int OT =
float>
651 OT tolerance = OT{0.0002})
676 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z, left.
w + right.
w };
683 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z, left.
w + right.
w };
690 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z, left.
w - right.
w };
697 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z, left.
w - right.
w };
704 return { left.
x * right.
x, left.
y * right.
y, left.
z * right.
z, left.
w * right.
w };
711 return { left.
x * right.
x, left.
y * right.
y, left.
z * right.
z, left.
w * right.
w };
718 return { left.
x * scalar, left.
y * scalar, left.
z * scalar, left.
w * scalar };
725 return { scalar * right.
x, scalar * right.
y, scalar * right.
z, scalar * right.
w };
732 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z, left.
w / right.
w };
739 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z, left.
w / right.
w };
746 return { left.
x / right, left.
y / right, left.
z / right, left.
w / right };
765 return input.
x + input.
y + input.
z + input.
w;
783 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z) + (left.
w * right.
w);
801 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z) + (left.
w * right.
w);
837 return dot(left, right) / (left.
magnitude() * right.magnitude());
859 return { std::abs(input.
x),
875 return { std::modf(input.
x, &dummy),
876 std::modf(input.
y, &dummy),
877 std::modf(input.
z, &dummy),
878 std::modf(input.
w, &dummy) };
895 float percentage_zero_to_one)
897 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
904 float percentage_zero_to_one)
906 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
913 float percentage_zero_to_one)
915 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
922 float percentage_zero_to_one)
924 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
929 return std::format(
"[x: {:.6}, y: {:.6}, z: {:.6}, w: {:.6}]", input.
x, input.
y, input.
z, input.
w);
950 template <
class U, std::
floating_po
int OT =
float>
954 OT tolerance = OT{0.0002})
958 auto diff{ near_to - input };
960 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
979 template <
class U, std::
floating_po
int OT =
float>
983 OT tolerance = OT{0.0002})
987 auto diff{ near_to - input };
989 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
1008 template <
class U, std::
floating_po
int OT =
float>
1012 OT tolerance = OT{0.0002})
1016 auto diff{ near_to - input };
1018 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
1037 template <
class U, std::
floating_po
int OT =
float>
1041 OT tolerance = OT{0.0002})
1045 auto diff{ near_to - input };
1047 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
1077 template <
class U, std::
floating_po
int OT =
float>
1081 OT tolerance = OT{0.0002})
1094 template <
class U, std::
floating_po
int OT =
float>
1098 OT tolerance = OT{0.0002})
1111 template <
class U, std::
floating_po
int OT =
float>
1115 OT tolerance = OT{0.0002})
1128 template <
class U, std::
floating_po
int OT =
float>
1132 OT tolerance = OT{0.0002})
1144 template <std::
floating_po
int OT =
float>
friend void CHECK_IF_ZERO(const BasicVector4D< Type > &input, OT tolerance=OT{0.0002})
friend void CHECK_IF_EQUAL(const BasicVector4D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_EQUAL(const BasicVector4D &input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(const BasicVector4D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(const BasicVector4D &input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
constexpr value_type normSquared() const
constexpr BasicVector3D< Type >::ConstRef xxx() const &
constexpr BasicVector3D< Type >::ConstRef xzy() const &
constexpr BasicVector2D< Type > zx() &&
constexpr BasicVector2D< Type >::Ref xz() &
static constexpr BasicVector4D< Type > unit_x()
friend constexpr BasicVector4D< RType > lerp(BasicRef input_lower_bound, BasicVector4D< U > &input_upper_bound, float percentage_zero_to_one)
friend std::string format(BasicRef input)
constexpr BasicVector4D()=default
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})
constexpr BasicVector3D< Type > zzz() &&
constexpr BasicVector3D< Type > xyz() &&
constexpr BasicVector3D< Type > zxy() &&
constexpr BasicRef(const BasicVector4D< RType > &other)
friend constexpr BasicVector4D< RType > operator/(BasicRef left, BasicRef< U > right)
constexpr value_type magnitude() const
constexpr BasicVector4D< Type > & operator=(const BasicVector4D &other)=default
constexpr BasicRef & operator=(BasicRef input)
constexpr BasicVector3D< Type >::ConstRef xyz() const &
constexpr BasicVector2D< Type > xy() &&
constexpr BasicVector3D< Type >::ConstRef zxy() const &
constexpr BasicRef(RType &x_in, RType &y_in, RType &z_in, RType &w_in)
static constexpr BasicVector4D< Type > unit_z()
constexpr BasicVector2D< Type >::Ref yz() &
friend constexpr BasicVector4D< Type > saturate(const BasicVector4D< Type > &input, Type lower_bound, Type upper_bound)
friend constexpr bool operator==(const BasicVector4D &left, const BasicVector4D< U > &right)
constexpr BasicVector3D< Type >::Ref www() &
constexpr BasicVector3D< Type >::ConstRef yyy() const &
friend bool check_if_equal(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type >::Ref zx() &
friend constexpr BasicVector4D< RType > operator*(BasicRef left, BasicRef< U > right)
friend void CHECK_IF_ZERO(BasicRef input, OT tolerance=OT{0.0002})
constexpr BasicVector3D< Type > xxx() &&
constexpr BasicVector3D< Type >::Ref zzz() &
friend constexpr bool approximately_equal_to(const BasicVector4D &value_to_test, const BasicVector4D< U > &value_it_should_be, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type > xz() &&
constexpr value_type norm() const
friend constexpr BasicVector4D< RType > operator+(BasicRef left, BasicRef< U > right)
constexpr BasicRef(const BasicRef &)=default
friend constexpr bool approximately_equal_to(const BasicVector4D &value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
friend constexpr BasicVector4D< Type > lerp(const BasicVector4D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
static constexpr BasicVector4D< Type > zero()
constexpr BasicVector2D< Type >::ConstRef yx() const &
friend constexpr bool approximately_equal_to(BasicRef value_to_test, const BasicVector4D< U > &value_it_should_be, OT tolerance=OT{0.0002})
friend BasicVector4D< RType > fract(BasicRef input)
constexpr value_type magnitudeSquared() const
RType value_type
The underlying implementation type.
BasicRef< const Type > ConstRef
constexpr BasicVector2D< Type >::Ref xy() &
static constexpr BasicVector4D< Type > unit_w()
friend constexpr BasicVector4D< Type > abs(const BasicVector4D< Type > &input)
friend constexpr BasicVector4D< RType > saturate(BasicRef input, RType lower_bound, RType upper_bound)
friend constexpr BasicVector4D< RType > normalized(BasicRef input)
friend constexpr Type dot(const BasicVector4D &left, BasicRef< U > right)
constexpr BasicVector3D< Type >::Ref zxy() &
friend bool check_if_equal(BasicRef input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr Type dot(const BasicVector4D &left, const BasicVector4D< U > &right)
friend constexpr BasicVector4D< Type > normalized(const BasicVector4D< Type > &input)
constexpr BasicVector3D< Type >::Ref zyx() &
constexpr BasicVector3D< Type > yyy() &&
friend constexpr BasicVector4D< RType > abs(BasicRef input)
constexpr BasicVector3D< Type >::Ref yyy() &
friend constexpr BasicVector4D< RType > operator-(BasicRef left, BasicRef< U > right)
friend constexpr Type accumulate(const BasicVector4D< Type > &input)
friend constexpr BasicVector4D< RType > mix(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector3D< Type >::Ref xxx() &
friend constexpr RType dot(BasicRef left, const BasicVector4D< U > &right)
friend constexpr bool operator==(BasicRef left, BasicRef< U > right)
friend constexpr RType dot_normalized(BasicRef left, BasicRef< U > right)
friend void CHECK_IF_NOT_EQUAL(BasicRef input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type >::ConstRef yz() const &
constexpr BasicVector3D< Type >::ConstRef www() const &
constexpr BasicVector2D< Type >::ConstRef xy() const &
constexpr BasicVector4D(const BasicVector2D< Type > &first2, const BasicVector2D< Type > &second2)
constexpr BasicVector3D< Type >::Ref xyz() &
friend constexpr RType dot_normalized(BasicRef left, const BasicVector4D< U > &right)
friend std::string format(const BasicVector4D &input)
friend constexpr Type dot_normalized(const BasicVector4D &left, const BasicVector4D< U > &right)
constexpr BasicVector2D< Type >::ConstRef xz() const &
constexpr BasicVector4D< Type > normalized() const
friend constexpr Type dot_normalized(const BasicVector4D &left, BasicRef< U > right)
friend constexpr RType dot(BasicRef left, BasicRef< U > right)
constexpr BasicVector4D(const BasicVector3D< Type > &first3, const Type &w_in=0)
constexpr BasicVector3D< Type > xzy() &&
constexpr BasicVector2D< Type > yx() &&
static constexpr BasicVector4D< Type > unit_y()
friend constexpr BasicVector4D< Type > mix(const BasicVector4D &input_lower_bound, const BasicVector4D< U > &input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector3D< Type > zyx() &&
constexpr BasicVector2D< Type > yz() &&
constexpr BasicVector2D< Type >::ConstRef zx() const &
constexpr BasicVector4D(const Type &x_in, const BasicVector3D< Type > &last3)
constexpr BasicVector4D(const Type &x_in, const Type &y_in=0, const Type &z_in=0, const Type &w_in=0)
constexpr BasicVector3D< Type > www() &&
constexpr BasicVector3D< Type >::ConstRef zyx() const &
friend bool check_if_not_equal(BasicRef input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector4D< RType > mix(BasicRef input_lower_bound, BasicVector4D< U > &input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector4D< RType > lerp(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector3D< Type >::ConstRef zzz() const &
Type value_type
The underlying implementation type.
friend constexpr BasicVector4D< Type > lerp(const BasicVector4D &input_lower_bound, const BasicVector4D< U > &input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector2D< Type >::Ref yx() &
friend constexpr BasicVector4D< Type > mix(const BasicVector4D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend constexpr RType accumulate(BasicRef input)
constexpr BasicVector3D< Type >::Ref xzy() &
friend BasicVector4D< Type > fract(const BasicVector4D< Type > &input)
BasicVector4D< double >::ConstRef Vector4DConstRef
BasicVector4D< double >::Ref Vector4DdRef
BasicVector4D< float >::Ref Vector4DfRef
BasicVector4D< float >::ConstRef Vector4DfConstRef
BasicVector4D< long double >::Ref Vector4DlRef
BasicVector4D< double >::Ref Vector4DRef
BasicVector4D< long double >::ConstRef Vector4DlConstRef
BasicVector4D< double >::ConstRef Vector4DdConstRef
friend bool check_if_equal(const BasicVector4D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(const BasicVector4D &input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(const BasicVector4D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend bool check_if_equal(const BasicVector4D &input, const BasicVector4D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector4D< Type > operator-(const BasicVector4D &left, const BasicVector4D< U > &right)
friend constexpr BasicVector4D< Type > operator/(const BasicVector4D &left, const BasicVector4D< U > &right)
friend constexpr BasicVector4D< Type > operator*(const BasicVector4D &left, const BasicVector4D< U > &right)
friend constexpr BasicVector4D< Type > operator+(const BasicVector4D &left, const BasicVector4D< U > &right)
constexpr const Type & saturate(const Type &value, const Type &lower_bound, const Type &upper_bound)