39 template <
class RType>
48 constexpr BasicRef(RType &x_in, RType &y_in, RType &z_in) :
x{x_in},
y{y_in},
z{z_in} { }
70 constexpr operator std::tuple<RType, RType, RType>()
const {
return std::make_tuple(
x,
y,
z ); }
94 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z };
101 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z };
108 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z };
115 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z };
122 return { left.
x * right.
x, left.
y * right.
y, left.
z * right.
z };
129 return { left.
x * right.
x, left.
y * right.
y, left.
z * right.
z };
136 return { left.
x * scalar, left.
y * scalar, left.
z * scalar };
143 return { scalar * right.
x, scalar * right.
y, scalar * right.
z };
150 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z };
157 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z };
164 return { left.
x / scalar, left.
y / scalar, left.
z / scalar };
167 template <
class U, std::
floating_po
int OT =
float>
171 OT tolerance = OT{0.0002})
178 template <
class U, std::
floating_po
int OT =
float>
182 OT tolerance = OT{0.0002})
191 return input.
x + input.
y + input.
z;
198 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z);
205 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z);
212 return dot(left, right) / (left.magnitude() * right.magnitude());
219 return dot(left, right) / (left.magnitude() * right.
magnitude());
236 return { std::abs(input.
x), std::abs(input.
y), std::abs(input.
z) };
243 return { std::modf(input.
x, &dummy),
244 std::modf(input.
y, &dummy),
245 std::modf(input.
z, &dummy) };
259 float percentage_zero_to_one)
261 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
268 float percentage_zero_to_one)
270 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
277 float percentage_zero_to_one)
279 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
286 float percentage_zero_to_one)
288 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
293 return std::format(
"[x: {:.6}, y: {:.6}, z: {:.6}]", input.
x, input.
y, input.
z);
296 template <
class U, std::
floating_po
int OT =
float>
300 OT tolerance = OT{0.0002})
304 auto diff{ near_to - input };
306 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
317 template <
class U, std::
floating_po
int OT =
float>
321 OT tolerance = OT{0.0002})
325 auto diff{ near_to - input };
327 std::cout << std::format(
"input: {} is not equal to near_to: {} within tolerance: {}. Difference is {} .",
338 template <
class U, std::
floating_po
int OT =
float>
342 OT tolerance = OT{0.0002})
346 auto diff{ near_to - input };
348 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
359 template <
class U, std::
floating_po
int OT =
float>
363 OT tolerance = OT{0.0002})
367 auto diff{ near_to - input };
369 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
380 template <
class U, std::
floating_po
int OT =
float>
384 OT tolerance = OT{0.0002})
389 template <
class U, std::
floating_po
int OT =
float>
393 OT tolerance = OT{0.0002})
398 template <
class U, std::
floating_po
int OT =
float>
402 OT tolerance = OT{0.0002})
407 template <
class U, std::
floating_po
int OT =
float>
411 OT tolerance = OT{0.0002})
416 template <std::
floating_po
int OT =
float>
430 constexpr BasicVector3D(
const Type &x_in,
const Type &y_in = 0,
const Type &z_in = 0)
453 x{ std::get<0>(init_value) },
454 y{ std::get<1>(init_value) },
455 z{ std::get<2>(init_value) }
475 constexpr operator std::tuple<Type, Type, Type>()
const {
return std::make_tuple(
x,
y,
z ); }
498 return {
x / n,
y / n,
z / n };
504 bool isNaN()
const {
return std::isnan(
x) || std::isnan(
y) || std::isnan(
z); }
505 bool isInf()
const {
return std::isinf(
x) || std::isinf(
y) || std::isinf(
z); }
598 template <
class U, std::
floating_po
int OT =
float>
602 OT tolerance = OT{0.0002})
617 template <
class U, std::
floating_po
int OT =
float>
621 OT tolerance = OT{0.0002})
645 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z };
652 return { left.
x + right.
x, left.
y + right.
y, left.
z + right.
z };
659 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z };
666 return { left.
x - right.
x, left.
y - right.
y, left.
z - right.
z };
673 return { left.
x * right.
x, left.
y * right.
y, left.
z * right.
z };
680 return { left.
x * right, left.
y * right, left.
z * right };
687 return { left.
x * scalar, left.
y * scalar, left.
z * scalar };
694 return { scalar * right.
x, scalar * right.
y };
701 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z };
708 return { left.
x / right.
x, left.
y / right.
y, left.
z / right.
z };
713 return { left.
x / right, left.
y / right, left.
z / right };
732 return input.
x + input.
y + input.
z;
750 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z);
768 return (left.
x * right.
x) + (left.
y * right.
y) + (left.
z * right.
z);
804 return dot(left, right) / (left.
magnitude() * right.magnitude());
845 return {
cross( left.
yz(), right.yz() ),
846 cross( left.
zx(), right.zx() ),
847 cross( left.
xy(), right.xy() ) };
858 return { std::abs(input.
x), std::abs(input.
y), std::abs(input.
z) };
871 return { std::modf(input.
x, &dummy), std::modf(input.
y, &dummy), std::modf(input.
z, &dummy) };
887 float percentage_zero_to_one)
889 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
896 float percentage_zero_to_one)
898 return (input_upper_bound - input_lower_bound) * percentage_zero_to_one + input_lower_bound;
905 float percentage_zero_to_one)
907 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
914 float percentage_zero_to_one)
916 return lerp( input_lower_bound, input_upper_bound, percentage_zero_to_one );
921 return std::format(
"[x: {:.6}, y: {:.6}, z: {:.6}]", input.
x, input.
y, input.
z);
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 not 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 not equal to near_to: {} within tolerance: {}. Difference is {} .",
1000 template <
class U, std::
floating_po
int OT =
float>
1004 OT tolerance = OT{0.0002})
1008 auto diff{ near_to - input };
1010 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
1029 template <
class U, std::
floating_po
int OT =
float>
1033 OT tolerance = OT{0.0002})
1037 auto diff{ near_to - input };
1039 std::cout << std::format(
"input: {} is equal to near_to: {} within tolerance: {}. Difference is {} .",
1069 template <
class U, std::
floating_po
int OT =
float>
1073 OT tolerance = OT{0.0002})
1086 template <
class U, std::
floating_po
int OT =
float>
1090 OT tolerance = OT{0.0002})
1103 template <
class U, std::
floating_po
int OT =
float>
1107 OT tolerance = OT{0.0002})
1120 template <
class U, std::
floating_po
int OT =
float>
1124 OT tolerance = OT{0.0002})
1136 template <std::
floating_po
int OT =
float>
friend void CHECK_IF_NOT_EQUAL(const BasicVector3D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_EQUAL(const BasicVector3D &input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_ZERO(const BasicVector3D< Type > &input, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(const BasicVector3D &input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
friend void CHECK_IF_EQUAL(const BasicVector3D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr value_type normSquared() const
friend constexpr bool operator==(const BasicVector3D &left, const BasicVector3D< U > &right)
friend constexpr bool approximately_equal_to(const BasicVector3D &value_to_test, BasicRef< U > value_it_should_be, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type > zx() &&
friend constexpr Type dot(const BasicVector3D &left, BasicRef< U > right)
constexpr BasicVector2D< Type >::Ref xz() &
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 BasicVector3D< Type > normalized(const BasicVector3D< Type > &input)
constexpr BasicVector3D< Type > xyz() &&
friend void CHECK_IF_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector3D< Type > zxy() &&
constexpr value_type magnitude() const
constexpr BasicRef & operator=(BasicRef input)
friend constexpr BasicVector3D< Type > lerp(const BasicVector3D &input_lower_bound, const BasicVector3D< U > &input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector2D< Type > xy() &&
static constexpr BasicVector3D< Type > unit_x()
friend bool check_if_equal(BasicRef input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector3D< RType > operator*(BasicRef left, BasicRef< U > right)
constexpr BasicVector2D< Type >::Ref yz() &
friend bool check_if_equal(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type >::Ref zx() &
friend constexpr RType dot_normalized(BasicRef left, const BasicVector3D< U > &right)
friend constexpr BasicVector3D< Type > mix(const BasicVector3D &input_lower_bound, const BasicVector3D< U > &input_upper_bound, float percentage_zero_to_one)
friend void CHECK_IF_ZERO(BasicRef input, OT tolerance=OT{0.0002})
friend void CHECK_IF_NOT_EQUAL(BasicRef input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
constexpr BasicVector3D(const std::tuple< Type, Type, Type > &init_value)
friend constexpr bool approximately_equal_to(BasicRef value_to_test, const BasicVector3D< U > &value_it_should_be, OT tolerance=OT{0.0002})
static constexpr BasicVector3D< Type > unit_y()
friend void CHECK_IF_EQUAL(BasicRef input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type > xz() &&
constexpr value_type norm() const
constexpr BasicRef(const BasicRef &)=default
friend constexpr BasicVector3D< Type > cross(const BasicVector3D &left, const BasicVector3D< U > &right)
friend constexpr BasicVector3D< RType > mix(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
static constexpr BasicVector3D< Type > unit_z()
friend constexpr BasicVector3D< RType > cross(BasicRef left, BasicRef< U > right)
friend constexpr BasicVector3D< RType > operator+(BasicRef left, BasicRef< U > right)
constexpr BasicVector2D< Type >::ConstRef yx() const &
friend constexpr Type dot_normalized(const BasicVector3D &left, BasicRef< U > right)
constexpr ConstRef xyz() const &
friend constexpr BasicVector3D< Type > saturate(const BasicVector3D< Type > &input, Type lower_bound, Type upper_bound)
constexpr value_type magnitudeSquared() const
static constexpr BasicVector3D< Type > zero()
RType value_type
The underlying implementation type.
friend constexpr BasicVector3D< RType > abs(BasicRef input)
BasicRef< const Type > ConstRef
constexpr BasicVector2D< Type >::Ref xy() &
constexpr ConstRef zxy() const &
friend std::string format(const BasicVector3D< Type > &input)
friend constexpr BasicVector3D< RType > lerp(BasicRef input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector3D< RType > saturate(BasicRef input, RType lower_bound, RType upper_bound)
friend constexpr BasicVector3D< RType > normalized(BasicRef input)
friend constexpr BasicVector3D< RType > mix(BasicRef input_lower_bound, const BasicVector3D< U > &input_upper_bound, float percentage_zero_to_one)
constexpr BasicVector3D(Type x_in, const BasicVector2D< Type > &other)
friend constexpr Type dot_normalized(const BasicVector3D &left, const BasicVector3D< U > &right)
constexpr BasicRef(RType &x_in, RType &y_in, RType &z_in)
friend constexpr BasicVector3D< Type > abs(const BasicVector3D< Type > &input)
friend constexpr Type accumulate(const BasicVector3D< Type > &input)
friend constexpr bool operator==(BasicRef left, BasicRef< U > right)
friend constexpr RType dot_normalized(BasicRef left, BasicRef< U > right)
constexpr BasicVector3D()=default
constexpr BasicVector3D< Type > normalized() const
friend void CHECK_IF_NOT_EQUAL(BasicRef input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
constexpr BasicVector3D< Type > & operator=(const BasicVector3D &other)=default
constexpr BasicVector2D< Type >::ConstRef yz() const &
constexpr BasicVector2D< Type >::ConstRef xy() const &
constexpr BasicVector2D< Type >::ConstRef xz() const &
friend constexpr BasicVector3D< RType > lerp(BasicRef input_lower_bound, const BasicVector3D< U > &input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector3D< RType > operator-(BasicRef left, BasicRef< U > right)
friend constexpr RType dot(BasicRef left, BasicRef< U > right)
constexpr BasicVector3D< Type > xzy() &&
friend constexpr RType dot(BasicRef left, const BasicVector3D< U > &right)
constexpr BasicVector3D(const BasicVector2D< Type > &other, Type z_in=0)
friend constexpr BasicVector3D< Type > cross(const BasicVector3D &left, BasicRef< U > right)
constexpr BasicVector2D< Type > yx() &&
friend constexpr BasicVector3D< RType > fract(BasicRef input)
constexpr BasicVector3D< Type > zyx() &&
constexpr BasicVector2D< Type > yz() &&
friend constexpr bool approximately_equal_to(const BasicVector3D &value_to_test, const BasicVector3D< U > &value_it_should_be, OT tolerance=OT{0.0002})
constexpr BasicVector2D< Type >::ConstRef zx() const &
friend constexpr BasicVector3D< RType > operator/(BasicRef left, BasicRef< U > right)
constexpr ConstRef zyx() const &
friend constexpr BasicVector3D< Type > mix(const BasicVector3D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend constexpr BasicVector3D< Type > lerp(const BasicVector3D &input_lower_bound, BasicRef< U > input_upper_bound, float percentage_zero_to_one)
friend constexpr Type dot(const BasicVector3D &left, const BasicVector3D< U > &right)
friend bool check_if_not_equal(BasicRef input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
constexpr BasicRef(const BasicVector3D< RType > &other)
constexpr ConstRef xzy() const &
Type value_type
The underlying implementation type.
constexpr BasicVector2D< Type >::Ref yx() &
friend constexpr BasicVector3D< Type > fract(const BasicVector3D< Type > &input)
friend constexpr RType accumulate(BasicRef input)
constexpr BasicVector3D(const Type &x_in, const Type &y_in=0, const Type &z_in=0)
BasicVector3D< float >::Ref Vector3DfRef
BasicVector3D< double >::Ref Vector3DRef
BasicVector3D< long double >::Ref Vector3DlRef
BasicVector3D< double >::ConstRef Vector3DdConstRef
BasicVector3D< float >::ConstRef Vector3DfConstRef
BasicVector3D< double >::Ref Vector3DdRef
BasicVector3D< double >::ConstRef Vector3DConstRef
BasicVector3D< long double >::ConstRef Vector3DlConstRef
friend bool check_if_equal(const BasicVector3D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(const BasicVector3D &input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
friend bool check_if_equal(const BasicVector3D &input, const BasicVector3D< U > &near_to, OT tolerance=OT{0.0002})
friend bool check_if_not_equal(const BasicVector3D &input, BasicRef< U > near_to, OT tolerance=OT{0.0002})
friend constexpr BasicVector3D< Type > operator+(const BasicVector3D &left, const BasicVector3D< U > &right)
friend constexpr BasicVector3D< Type > operator*(const BasicVector3D &left, const BasicVector3D< U > &right)
friend constexpr BasicVector3D< Type > operator/(const BasicVector3D &left, const BasicVector3D< U > &right)
friend constexpr BasicVector3D< Type > operator-(const BasicVector3D &left, const BasicVector3D< U > &right)
constexpr const Type & saturate(const Type &value, const Type &lower_bound, const Type &upper_bound)