33#include <NDEVR/Vector.h>
57 template<
class t_vector_type, u
int01 t_dims,
class t_type>
58 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, t_type>, t_vector_type>::value, t_vector_type>::type
62 for (
uint01 dim = 0; dim < t_dims; ++dim)
63 sum[dim] = vec_a[dim] + vec_b[dim];
81 template<u
int01 t_dims,
class t_type>
85 for (
uint01 dim = 0; dim < t_dims; ++dim)
86 sum[dim] = scaler_a + vec_b[dim];
104 template<
class t_vector_type,
class t_type>
105 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
106 operator+(
const t_vector_type& vec_a,
const t_type& scaler_b)
109 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
110 sum[dim] = vec_a[dim] + scaler_b;
113 template<
class t_vector_type,
class t_type>
114 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
115 operator+(
const t_type& scaler_a,
const t_vector_type& vec_b)
118 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
119 sum[dim] = scaler_a + vec_b[dim];
137 template<u
int01 t_dims,
class t_type>
140 for (
uint01 dim = 0; dim < t_dims; ++dim)
141 vec_a[dim] += vec_b[dim];
159 template<u
int01 t_dims,
class t_type>
162 for (
uint01 dim = 0; dim < t_dims; ++dim)
163 vec_a[dim] += scaler_b;
181 template<
class t_vector_type, u
int01 t_dims,
class t_type>
182 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, t_type>, t_vector_type>::value, t_vector_type>::type
185 t_vector_type difference;
186 for (
uint01 dim = 0; dim < t_dims; ++dim)
187 difference[dim] = vec_a[dim] - vec_b[dim];
205 template<u
int01 t_dims,
class t_type>
209 for (
uint01 dim = 0; dim < t_dims; ++dim)
210 difference[dim] = value_a - vec_b[dim];
228 template<
class t_vector_type,
class t_type>
229 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
230 operator-(
const t_vector_type& vec_a,
const t_type& value_b)
232 t_vector_type difference;
233 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
234 difference[dim] = vec_a[dim] - value_b;
252 template<u
int01 t_dims,
class t_type>
255 for (
uint01 dim = 0; dim < t_dims; ++dim)
256 vec_a[dim] -= vec_b[dim];
274 template<u
int01 t_dims,
class t_type>
277 for (
uint01 dim = 0; dim < t_dims; ++dim)
278 vec_a[dim] -= value_b;
296 template<u
int01 t_dims,
class t_type>
300 for (
uint01 dim = 0; dim < t_dims; ++dim)
301 product[dim] = vec_a[dim] * vec_b[dim];
319 template<
class t_vector_type,
class t_type>
320 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
321 operator*(
const t_type& value_a,
const t_vector_type& vec_b)
323 t_vector_type product;
324 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
325 product[dim] = value_a * vec_b[dim];
343 template<
class t_vector_type,
class t_type>
344 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
345 operator*(
const t_vector_type& vec_a,
const t_type& value_b)
347 t_vector_type product;
348 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
349 product[dim] = vec_a[dim] * value_b;
367 template<u
int01 t_dims,
class t_type>
370 for (
uint01 dim = 0; dim < t_dims; ++dim)
371 vec_a[dim] *= vec_b[dim];
389 template<u
int01 t_dims,
class t_type>
392 for (
uint01 dim = 0; dim < t_dims; ++dim)
393 vec_a[dim] *= value_b;
411 template<u
int01 t_dims,
class t_type>
415 for (
uint01 dim = 0; dim < t_dims; ++dim)
416 quotient[dim] = vec_a[dim] / vec_b[dim];
434 template<
class t_vector_type,
class t_type>
435 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
436 operator/(
const t_type& value_a,
const t_vector_type& vec_b)
438 t_vector_type quotient;
439 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
440 quotient[dim] = value_a / vec_b[dim];
458 template<
class t_vector_type,
class t_type>
459 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
460 operator/(
const t_vector_type& vec_a,
const t_type& value_b)
462 t_vector_type quotient;
463 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
464 quotient[dim] = vec_a[dim] / value_b;
493 template<u
int01 t_dims,
class t_type>
497 for (
uint01 dim = 0; dim < t_dims; ++dim)
498 mod [dim] = std::fmod(vec_a[dim], vec_b[dim]);
501 template<u
int01 t_dims,
class t_type>
505 for (
uint01 dim = 0; dim < t_dims; ++dim)
525 template<u
int01 t_dims,
class t_type>
528 for (
uint01 dim = 0; dim < t_dims; ++dim)
529 vec_a[dim] = vec_a[dim] / vec_b[dim];
548 template<u
int01 t_dims,
class t_type>
551 for (
uint01 dim = 0; dim < t_dims; ++dim)
552 vec_a[dim] = vec_a[dim] / value_b;
556 template<
class t_vector_type,
class t_type>
557 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
560 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
567 template<
class t_vector_type,
class t_type>
568 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
571 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
578 template<
class t_vector_type>
579 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
580 operator==(
const t_vector_type& v_a,
const t_vector_type& v_b)
582 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
584 if (v_a[dim] != v_b[dim])
589 template<
class t_type>
590 constexpr typename std::enable_if<!IsVec<t_type>::value,
bool>::type
595 template<
class t_type>
596 constexpr typename std::enable_if<!IsVec<t_type>::value,
bool>::type
597 AreSame(
const t_type& a,
const t_type& b,
const t_type& epsilon)
600 ||
::abs(a - b) < epsilon;
603 template<
class t_vector_type>
604 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
605 AreSame(
const t_vector_type& v_a,
const t_vector_type& v_b)
607 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
609 if (!
AreSame(v_a[dim], v_b[dim]))
614 template<
class t_vector_type,
class t_type>
615 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
616 AreSame(
const t_vector_type& v_a,
const t_vector_type& v_b,
const t_type& epsilon)
619 ||
abs(v_a - v_b) < epsilon;
621 template<
class t_vector_type>
622 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
623 operator!=(
const t_vector_type& v_a,
const t_vector_type& v_b)
625 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
627 if (v_a[dim] != v_b[dim])
632 template<
class t_vector_type,
class t_type>
633 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
636 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
643 template<
class t_vector_type,
class t_type>
644 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
647 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
669 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
673 for (
uint01 dim = 0; dim < min_val; ++dim)
675 if (!(v1[dim] >= v2[dim]))
681 template<u
int01 t_dims,
class t_type>
684 for (
uint01 dim = 0; dim < t_dims; ++dim)
707 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
711 for (
uint01 dim = 0; dim < min_val; ++dim)
713 if (!(v1[dim] > v2[dim]))
719 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
722 const t_type min_val =
getMin(vec_1_size, vec_2_size);
723 for (
uint01 dim = 0; dim < min_val; ++dim)
725 if (!(v1[dim] < v2[dim]))
730 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
734 for (
uint01 dim = 0; dim < min_val; ++dim)
736 if (!(v1[dim] <= v2[dim]))
755 template<u
int01 t_dims,
class t_type>
758 for (
uint01 dim = 0; dim < t_dims; ++dim)
760 if (!(v1[dim] >= v2[dim]))
781 template<u
int01 t_dims,
class t_type>
784 for (
uint01 dim = 0; dim < t_dims; dim++)
786 if (!(v1[dim] > v2[dim]))
792 template<u
int01 t_dims,
class t_type>
795 for (
uint01 dim = 0; dim < t_dims; dim++)
797 if (!(v1[dim] < v2[dim]))
803 template<
class t_vector_type,
class t_type>
804 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
805 operator<(
const t_vector_type& v,
const t_type& s)
807 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
814 template<
class t_vector_type,
class t_type>
815 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
816 operator<(
const t_type& s,
const t_vector_type& v)
818 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
825 template<
class t_vector_type,
class t_type>
826 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
827 operator<=(
const t_type& s,
const t_vector_type& v)
829 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
837 template<
class t_vector_type,
class t_type>
838 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
839 operator<=(
const t_vector_type& v,
const t_type& s)
841 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
848 template<
class t_vector_type,
class t_type>
849 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
852 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
859 template<
class t_vector_type,
class t_type>
860 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
863 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
871 template<u
int01 t_dims,
class t_type>
874 for (
uint01 dim = 0; dim < t_dims; dim++)
876 if (!(v1[dim] <= v2[dim]))
897 template<
class t_type>
902 template<
class t_type>
905 return v1[
X] * v2[
Y] - v1[
Y] * v2[
X];
907 template<
class t_type>
912 template<
class t_type>
916 cross[
X] = ((v1[
Y] * v2[
Z]) - (v1[
Z] * v2[
Y]));
917 cross[
Y] = ((v1[
Z] * v2[
X]) - (v1[
X] * v2[
Z]));
918 cross[
Z] = ((v1[
X] * v2[
Y]) - (v1[
Y] * v2[
X]));
936 template<u
int01 t_dims,
class t_type>
940 for (
uint01 dim = 0; dim < t_dims; dim++)
942 vec[dim] =
getMax(v1[dim], v2[dim]);
961 template<u
int01 t_dims,
class t_type>
965 for (
uint01 dim = 0; dim < t_dims; dim++)
967 vec[dim] =
getMin(v1[dim], v2[dim]);
986 template<u
int01 t_dims,
class t_type>
989 return (v1[
X] * v2[
Y]) - (v1[
Y] * v2[
X]);
1007 template<u
int01 t_dims,
class t_type>
1013 return x_det - y_det + z_det;
1029 template<u
int01 t_dims,
class t_type>
1033 for (
uint01 dim = 0; dim < t_dims; ++dim)
1034 value += v1[dim] * v2[dim];
1052 template<u
int01 t_dims,
class t_type>
1055 t_type magnitude_1 = v1.getMagnitudeSquared();
1056 t_type magnitude_2 = v2.getMagnitudeSquared();
1057 return v2 * v2 * (magnitude_1) == v1 * v1 * magnitude_2;
1075 template<u
int01 t_dims,
class t_type>
1078 return (
abs(left - right) < epsilon);
1094 template<
class t_type>
1095 constexpr typename std::enable_if<!IsVec<t_type>::value, t_type>::type
1098 return std::abs(value);
1101 template<
class t_type>
1102 constexpr typename std::enable_if<IsVec<t_type>::value, t_type>::type
1106 for (
uint01 dim = 0; dim < t_type::NumberOfDimensions(); ++dim)
1107 abs_value[dim] =
abs(value[dim]);
1111 template<
class t_to,
class t_from>
1114 return static_cast<t_to
>(value[0]);
1203 template<u
int01 t_dims,
class t_type>
1207 for (
uint01 dim = 0; dim < t_dims; ++dim)
1208 value[dim] =
abs(vector[dim]);
1224 template<
class t_type>
1227 return ::sqrt(value);
1242 template<u
int01 t_dims,
class t_type>
1246 for (
uint01 dim = 0; dim < t_dims; ++dim)
1248 vec[dim] = std::sqrt(vector[dim]);
1267 template<u
int01 t_dims,
class t_type>
1271 for (
uint01 dim = 0; dim < t_dims; ++dim)
1273 const t_type dn = (v1[dim] - v2[dim]);
1293 template<u
int01 t_dims,
class t_type>
1317 template<
class t_distance_type, u
int01 t_dims,
class t_type>
1323 template <u
int01 t_dims,
typename t_type>
1327 for (
uint01 i = 0; i < t_dims; i++)
1329 clipped[i] =
clip(value[i], lower_bound[i], upper_bound[i]);
Dummy class to include functions related to vector math.
Definition VectorFunctions.hpp:42
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
constexpr Vector< t_dims, t_type > operator/=(Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition VectorFunctions.hpp:526
bool operator==(const char(&v1)[t_size], const String &v2)
Definition String.h:912
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
Definition BaseFunctions.hpp:94
constexpr std::enable_if<!IsVec< t_type >::value, bool >::type AreSame(const t_type &a, const t_type &b)
Definition VectorFunctions.hpp:591
constexpr std::enable_if< IsVecType< t_vector_type, Angle< fltp08 > >::value, t_vector_type >::type operator*(const t_vector_type &angle, const t_type &mult)
Multiplication operator for a Vector of Angles.
Definition AngleFunctions.h:326
constexpr t_type clip(const t_type &value, const t_type &lower_bound, const t_type &upper_bound)
Clips the value given so that that the returned value falls between upper and lower bound.
Definition BaseFunctions.hpp:207
constexpr bool operator<(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:720
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1030
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:668
TimeSpan operator-(const Time &time, const Time &value)
constexpr bool operator<=(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:731
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
t_type determinate(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:987
String operator+(const String &string_a, const String &string_b)
Definition String.h:827
t_type distanceSquared(const Bounds< t_dims, t_type, t_vertex > &bounds, const Vector< t_dims, t_type > &vertex)
Definition Distance.hpp:46
String & operator+=(String &string, const String &value)
Definition String.h:889
constexpr bool operator>=(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:670
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
constexpr Vector< 1, t_type > cross(const Vector< 1, t_type > &, const Vector< 1, t_type > &)
Definition VectorFunctions.hpp:898
constexpr std::enable_if< IsVecType< t_vector_type, Angle< t_angle_type > >::value, t_vector_type >::type operator/(const t_vector_type &angle, const t_type &den)
Division operator for a Vector of Angles.
Definition AngleFunctions.h:456
constexpr bool operator>(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:708
constexpr RGBColor & operator*=(RGBColor &color, const t_type &value)
Definition RGBColor.h:222
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1225
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:171
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:88
constexpr bool equals(const LineSegment< t_dims, t_type, t_vertex > &left, const LineSegment< t_dims, t_type, t_vertex > &right, const t_type &epsilon=cast< t_type >(0))
Definition Line.hpp:757
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Changes an input with a negative sign, to a positive sign.
Definition AngleFunctions.h:645
bool AreParallel(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1053
Time & operator-=(Time &time, const TimeSpan &value)
constexpr Vector< t_dims, Angle< t_angle_type > > operator%(const Vector< t_dims, Angle< t_angle_type > > &vec_a, const Vector< t_dims, Angle< t_angle_type > > &vec_b)
Definition AngleFunctions.h:617
@ Y
Definition BaseValues.hpp:169
@ X
Definition BaseValues.hpp:167
@ Z
Definition BaseValues.hpp:171
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
Definition BaseFunctions.hpp:56