33#include <NDEVR/Vector.h>
63 template<
class t_vector_type, u
int01 t_dims,
class t_type>
64 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, t_type>, t_vector_type>::value, t_vector_type>::type
68 for (
uint01 dim = 0; dim < t_dims; ++dim)
69 sum[dim] = vec_a[dim] + vec_b[dim];
89 template<u
int01 t_dims,
class t_type>
93 for (
uint01 dim = 0; dim < t_dims; ++dim)
94 sum[dim] = scaler_a + vec_b[dim];
114 template<
class t_vector_type,
class t_type>
115 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
116 operator+(
const t_vector_type& vec_a,
const t_type& scaler_b)
119 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
120 sum[dim] = vec_a[dim] + scaler_b;
123 template<
class t_vector_type,
class t_type>
124 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
125 operator+(
const t_type& scaler_a,
const t_vector_type& vec_b)
128 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
129 sum[dim] = scaler_a + vec_b[dim];
149 template<u
int01 t_dims,
class t_type>
152 for (
uint01 dim = 0; dim < t_dims; ++dim)
153 vec_a[dim] += vec_b[dim];
173 template<u
int01 t_dims,
class t_type>
176 for (
uint01 dim = 0; dim < t_dims; ++dim)
177 vec_a[dim] += scaler_b;
197 template<
class t_vector_type, u
int01 t_dims,
class t_type>
198 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, t_type>, t_vector_type>::value, t_vector_type>::type
201 t_vector_type difference;
202 for (
uint01 dim = 0; dim < t_dims; ++dim)
203 difference[dim] = vec_a[dim] - vec_b[dim];
223 template<u
int01 t_dims,
class t_type>
227 for (
uint01 dim = 0; dim < t_dims; ++dim)
228 difference[dim] = value_a - vec_b[dim];
248 template<
class t_vector_type,
class t_type>
249 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
250 operator-(
const t_vector_type& vec_a,
const t_type& value_b)
252 t_vector_type difference;
253 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
254 difference[dim] = vec_a[dim] - value_b;
274 template<u
int01 t_dims,
class t_type>
277 for (
uint01 dim = 0; dim < t_dims; ++dim)
278 vec_a[dim] -= vec_b[dim];
298 template<u
int01 t_dims,
class t_type>
301 for (
uint01 dim = 0; dim < t_dims; ++dim)
302 vec_a[dim] -= value_b;
322 template<u
int01 t_dims,
class t_type>
326 for (
uint01 dim = 0; dim < t_dims; ++dim)
327 product[dim] = vec_a[dim] * vec_b[dim];
347 template<
class t_vector_type,
class t_type>
348 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
349 operator*(
const t_type& value_a,
const t_vector_type& vec_b)
351 t_vector_type product;
352 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
353 product[dim] = value_a * vec_b[dim];
373 template<
class t_vector_type,
class t_type>
374 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
375 operator*(
const t_vector_type& vec_a,
const t_type& value_b)
377 t_vector_type product;
378 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
379 product[dim] = vec_a[dim] * value_b;
399 template<u
int01 t_dims,
class t_type>
402 for (
uint01 dim = 0; dim < t_dims; ++dim)
403 vec_a[dim] *= vec_b[dim];
423 template<u
int01 t_dims,
class t_type>
426 for (
uint01 dim = 0; dim < t_dims; ++dim)
427 vec_a[dim] *= value_b;
447 template<u
int01 t_dims,
class t_type>
451 for (
uint01 dim = 0; dim < t_dims; ++dim)
452 quotient[dim] = vec_a[dim] / vec_b[dim];
472 template<
class t_vector_type,
class t_type>
473 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
474 operator/(
const t_type& value_a,
const t_vector_type& vec_b)
476 t_vector_type quotient;
477 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
478 quotient[dim] = value_a / vec_b[dim];
498 template<
class t_vector_type,
class t_type>
499 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value, t_vector_type>::type
500 operator/(
const t_vector_type& vec_a,
const t_type& value_b)
502 t_vector_type quotient;
503 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
504 quotient[dim] = vec_a[dim] / value_b;
535 template<u
int01 t_dims,
class t_type>
539 for (
uint01 dim = 0; dim < t_dims; ++dim)
540 mod [dim] = std::fmod(vec_a[dim], vec_b[dim]);
543 template<u
int01 t_dims,
class t_type>
547 for (
uint01 dim = 0; dim < t_dims; ++dim)
569 template<u
int01 t_dims,
class t_type>
572 for (
uint01 dim = 0; dim < t_dims; ++dim)
573 vec_a[dim] = vec_a[dim] / vec_b[dim];
594 template<u
int01 t_dims,
class t_type>
597 for (
uint01 dim = 0; dim < t_dims; ++dim)
598 vec_a[dim] = vec_a[dim] / value_b;
602 template<
class t_vector_type,
class t_type>
603 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
606 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
613 template<
class t_vector_type,
class t_type>
614 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
617 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
624 template<
class t_vector_type>
625 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
626 operator==(
const t_vector_type& v_a,
const t_vector_type& v_b)
628 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
630 if (v_a[dim] != v_b[dim])
635 template<
class t_type>
636 constexpr typename std::enable_if<!IsVec<t_type>::value,
bool>::type
641 template<
class t_type>
642 constexpr typename std::enable_if<!IsVec<t_type>::value,
bool>::type
643 AreSame(
const t_type& a,
const t_type& b,
const t_type& epsilon)
646 ||
abs(a - b) < epsilon;
649 template<
class t_vector_type>
650 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
651 AreSame(
const t_vector_type& v_a,
const t_vector_type& v_b)
653 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
655 if (!
AreSame(v_a[dim], v_b[dim]))
660 template<
class t_vector_type,
class t_type>
661 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
662 AreSame(
const t_vector_type& v_a,
const t_vector_type& v_b,
const t_type& epsilon)
665 ||
abs(v_a - v_b) < epsilon;
667 template<
class t_vector_type>
668 constexpr typename std::enable_if<IsVec<t_vector_type>::value,
bool>::type
669 operator!=(
const t_vector_type& v_a,
const t_vector_type& v_b)
671 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
673 if (v_a[dim] != v_b[dim])
678 template<
class t_vector_type,
class t_type>
679 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
682 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
689 template<
class t_vector_type,
class t_type>
690 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
693 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
717 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
721 for (
uint01 dim = 0; dim < min_val; ++dim)
723 if (!(v1[dim] >= v2[dim]))
729 template<u
int01 t_dims,
class t_type>
732 for (
uint01 dim = 0; dim < t_dims; ++dim)
757 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
761 for (
uint01 dim = 0; dim < min_val; ++dim)
763 if (!(v1[dim] > v2[dim]))
769 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
772 const t_type min_val =
getMin(vec_1_size, vec_2_size);
773 for (
uint01 dim = 0; dim < min_val; ++dim)
775 if (!(v1[dim] < v2[dim]))
780 template<u
int01 vec_1_size, u
int01 vec_2_size,
class t_type>
784 for (
uint01 dim = 0; dim < min_val; ++dim)
786 if (!(v1[dim] <= v2[dim]))
807 template<u
int01 t_dims,
class t_type>
810 for (
uint01 dim = 0; dim < t_dims; ++dim)
812 if (!(v1[dim] >= v2[dim]))
835 template<u
int01 t_dims,
class t_type>
838 for (
uint01 dim = 0; dim < t_dims; dim++)
840 if (!(v1[dim] > v2[dim]))
846 template<u
int01 t_dims,
class t_type>
849 for (
uint01 dim = 0; dim < t_dims; dim++)
851 if (!(v1[dim] < v2[dim]))
857 template<
class t_vector_type,
class t_type>
858 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
859 operator<(
const t_vector_type& v,
const t_type& s)
861 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
868 template<
class t_vector_type,
class t_type>
869 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
870 operator<(
const t_type& s,
const t_vector_type& v)
872 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
879 template<
class t_vector_type,
class t_type>
880 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
881 operator<=(
const t_type& s,
const t_vector_type& v)
883 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
891 template<
class t_vector_type,
class t_type>
892 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
893 operator<=(
const t_vector_type& v,
const t_type& s)
895 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
902 template<
class t_vector_type,
class t_type>
903 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
906 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
913 template<
class t_vector_type,
class t_type>
914 constexpr typename std::enable_if<IsVecType<t_vector_type, t_type>::value,
bool>::type
917 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); dim++)
925 template<u
int01 t_dims,
class t_type>
928 for (
uint01 dim = 0; dim < t_dims; dim++)
930 if (!(v1[dim] <= v2[dim]))
953 template<
class t_type>
958 template<
class t_type>
961 return v1[
X] * v2[
Y] - v1[
Y] * v2[
X];
963 template<
class t_type>
968 template<
class t_type>
972 cross[
X] = ((v1[
Y] * v2[
Z]) - (v1[
Z] * v2[
Y]));
973 cross[
Y] = ((v1[
Z] * v2[
X]) - (v1[
X] * v2[
Z]));
974 cross[
Z] = ((v1[
X] * v2[
Y]) - (v1[
Y] * v2[
X]));
994 template<u
int01 t_dims,
class t_type>
998 for (
uint01 dim = 0; dim < t_dims; dim++)
1000 vec[dim] =
getMax(v1[dim], v2[dim]);
1021 template<u
int01 t_dims,
class t_type>
1025 for (
uint01 dim = 0; dim < t_dims; dim++)
1027 vec[dim] =
getMin(v1[dim], v2[dim]);
1048 template<u
int01 t_dims,
class t_type>
1051 return (v1[
X] * v2[
Y]) - (v1[
Y] * v2[
X]);
1071 template<u
int01 t_dims,
class t_type>
1077 return x_det - y_det + z_det;
1095 template<u
int01 t_dims,
class t_type>
1099 for (
uint01 dim = 0; dim < t_dims; ++dim)
1100 value += v1[dim] * v2[dim];
1120 template<u
int01 t_dims,
class t_type>
1123 t_type magnitude_1 = v1.getMagnitudeSquared();
1124 t_type magnitude_2 = v2.getMagnitudeSquared();
1125 return v2 * v2 * (magnitude_1) == v1 * v1 * magnitude_2;
1145 template<u
int01 t_dims,
class t_type>
1148 return (
abs(left - right) < epsilon);
1166 template<
class t_type>
1167 constexpr typename std::enable_if<!IsVec<t_type>::value, t_type>::type
1170 return std::abs(value);
1173 template<
class t_type>
1174 constexpr typename std::enable_if<IsVec<t_type>::value, t_type>::type
1178 for (
uint01 dim = 0; dim < t_type::NumberOfDimensions(); ++dim)
1179 abs_value[dim] =
abs(value[dim]);
1183 template<
class t_to,
class t_from>
1186 return static_cast<t_to
>(value[0]);
1285 template<u
int01 t_dims,
class t_type>
1289 for (
uint01 dim = 0; dim < t_dims; ++dim)
1290 value[dim] =
abs(vector[dim]);
1308 template<
class t_type>
1311 return ::sqrt(value);
1328 template<u
int01 t_dims,
class t_type>
1332 for (
uint01 dim = 0; dim < t_dims; ++dim)
1334 vec[dim] = std::sqrt(vector[dim]);
1355 template<u
int01 t_dims,
class t_type>
1359 for (
uint01 dim = 0; dim < t_dims; ++dim)
1361 const t_type dn = (v1[dim] - v2[dim]);
1383 template<u
int01 t_dims,
class t_type>
1409 template<
class t_distance_type, u
int01 t_dims,
class t_type>
1415 template <u
int01 t_dims,
typename t_type>
1419 for (
uint01 i = 0; i < t_dims; i++)
1421 clipped[i] =
clip(value[i], lower_bound[i], upper_bound[i]);
Definition VectorFunctions.hpp:46
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
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:570
bool operator==(const char(&v1)[t_size], const String &v2)
Definition String.h:437
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator.
Definition BaseFunctions.hpp:116
constexpr std::enable_if<!IsVec< t_type >::value, bool >::type AreSame(const t_type &a, const t_type &b)
Definition VectorFunctions.hpp:637
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)
Definition AngleFunctions.h:403
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:240
constexpr bool operator<(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:770
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1096
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:724
constexpr bool operator<=(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:781
bool areParallel(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1121
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
NDEVR_BASE_API TimeSpan operator-(const Time &time, const Time &value)
Definition TimeSpan.cpp:204
t_type determinate(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1049
String operator+(const String &string_a, const String &string_b)
Definition String.h:352
t_type distanceSquared(const Bounds< t_dims, t_type, t_vertex > &bounds, const Vector< t_dims, t_type > &vertex)
Definition Distance.hpp:42
String & operator+=(String &string, const String &value)
Definition String.h:414
constexpr bool operator>=(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:718
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
constexpr Vector< 1, t_type > cross(const Vector< 1, t_type > &, const Vector< 1, t_type > &)
Definition VectorFunctions.hpp:954
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)
Definition AngleFunctions.h:459
constexpr bool operator>(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:758
NDEVR_BASE_API Time & operator-=(Time &time, const TimeSpan &value)
Definition TimeSpan.cpp:221
constexpr RGBColor & operator*=(RGBColor &color, const t_type &value)
Definition RGBColor.h:221
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1309
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:250
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
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:819
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Definition AngleFunctions.h:750
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
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:734
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator.
Definition BaseFunctions.hpp:67