33#include <NDEVR/BaseValues.h>
34#include <NDEVR/LibAssert.h>
58 template<u
int01 t_dims,
class t_type>
76 template<
class t_vec_type>
80 for (
uint01 dim = 0; dim < t_dims; ++dim)
95 constexpr explicit Vector(
const t_type& scaler) noexcept
98 for(
uint01 dim = 0; dim < t_dims; ++dim)
114 template<u
int01 tdims = t_dims>
115 constexpr Vector(
const t_type& x,
typename std::enable_if<tdims == 2, const t_type&>::type y)
118 static_assert(t_dims == 2,
"Unexpected Number of Dimensions. Vector Size Required: 2");
134 template<u
int01 tdims = t_dims>
135 constexpr Vector(
const t_type& x,
const t_type& y,
const typename std::enable_if<tdims == 3, const t_type&>::type z)
138 static_assert(t_dims == 3,
"Unexpected Number of Dimensions. Vector Size Required: 3");
155 template<u
int01 tdims = t_dims>
156 constexpr Vector(
const t_type& x,
const t_type& y,
const t_type& z,
typename std::enable_if<tdims == 4, const t_type&>::type w)
159 static_assert(t_dims == 4,
"Unexpected Number of Dimensions. Vector Size Required: 4");
162 template<u
int01 tdims = t_dims>
163 constexpr Vector(
const t_type& x,
const t_type& y,
const t_type& z,
const t_type& w,
typename std::enable_if<tdims == 5, const t_type&>::type v)
166 static_assert(t_dims == 5,
"Unexpected Number of Dimensions. Vector Size Required: 5");
169 template<u
int01 tdims = t_dims>
170 constexpr Vector(
const t_type& x,
const t_type& y,
const t_type& z,
const t_type& w,
const t_type& v,
typename std::enable_if<tdims == 6, const t_type&>::type u)
173 static_assert(t_dims == 6,
"Unexpected Number of Dimensions. Vector Size Required: 6");
175 template<u
int01 tdims = t_dims>
176 constexpr Vector(
const t_type& x,
const t_type& y,
const t_type& z,
const t_type& w,
const t_type& v,
const t_type& u,
const t_type& t,
const t_type& s,
typename std::enable_if<tdims == 9, const t_type&>::type r)
177 :
m_values{ x, y, z, w, v, u, t, s, r }
179 static_assert(t_dims == 9,
"Unexpected Number of Dimensions. Vector Size Required: 9");
191 constexpr explicit Vector(
const t_type(&vector)[t_dims])
194 for (
uint01 dim = 0; dim < t_dims; dim++)
209 template<u
int01 tdims = t_dims>
213 static_assert(t_dims >= 2,
"Unexpected Number of Dimensions. Vector Size Required: >= 2");
214 for(
uint01 dim = 0; dim < t_dims - 1; ++dim)
232 template<u
int01 tdims = t_dims>
233 constexpr Vector(
const Vector<
getMax(tdims - 2, 0), t_type>& vector,
const t_type& suffix_a,
typename std::enable_if<tdims >= 3,
const t_type&>::type suffix_b)
236 static_assert(t_dims >= 3,
"Unexpected Number of Dimensions. Vector Size Required: >= 3");
237 for(
uint01 dim = 0; dim < t_dims - 2; ++dim)
254 template<u
int01 tdims = t_dims>
258 static_assert(t_dims >= 2,
"Unexpected Number of Dimensions. Vector Size Required: >= 2");
260 for(
uint01 dim =
Y; dim < t_dims; ++dim)
275 template<u
int01 tdims = t_dims>
279 static_assert(t_dims >= 3,
"Unexpected Number of Dimensions. Vector Size Required: >= 3");
282 for (
uint01 dim =
Z; dim < t_dims; ++dim)
299 template<
class t_new_type>
303 for (
uint01 dim = 0; dim < t_dims; ++dim)
307 template<u
int01 t_new_dim,
class t_new_type>
312 for (
uint01 dim = 0; dim < min; ++dim)
316 template<u
int01 t_new_dim,
class t_new_type>
322 for(; dim < min; dim++)
324 for(; dim < t_new_dim; dim++)
325 vec[dim] = extra_fill_value;
339 template<LocationValues t_max_min>
343 for(
uint01 dim = 1; dim < t_dims; ++dim)
345 if constexpr(t_max_min ==
MAX)
369 template<LocationValues t_max_min>
373 for(
uint01 dim = 1; dim < t_dims; ++dim)
375 if constexpr (t_max_min ==
MAX)
399 template<
uint01 tdims = t_dims
400 ,
typename =
typename std::enable_if<tdims == 1>::type>
401 constexpr operator t_type&()
406 template<
uint01 tdims = t_dims
407 ,
typename =
typename std::enable_if<tdims == 1>::type>
408 constexpr operator const t_type &()
const
429 for(
uint01 dim = 0; dim < t_dims; ++dim)
447 template<
class t_magnitude_type = t_type>
463 template<
class t_norm_type = t_type>
471 for (
uint01 dim = 0; dim < t_dims; dim++)
488 [[nodiscard]]
constexpr t_type
product()
const
491 for(
uint01 dim = 1; dim < t_dims; ++dim)
505 [[nodiscard]]
constexpr t_type
sum()
const
508 for (
uint01 dim = 1; dim < t_dims; ++dim)
528 lib_assert(dimension_index < t_dims,
"Dimension requested Exceeded maximum vector dimension");
536 lib_assert(dimension_index < t_dims,
"Dimension requested Exceeded maximum vector dimension");
552 for(
uint01 dim = 0; dim < t_dims; ++dim)
592 for (
uint01 dim = 0; dim < t_dims; ++dim)
619 constexpr static t_type
Type() {
return t_type(); }
642 template<u
int01 t_dims,
class t_type>
645 for (
uint01 dim = 0; dim < t_dims; ++dim)
647 if (vec_a[dim] != vec_b[dim])
667 template<u
int01 t_dims,
class t_type>
670 for (
uint01 dim = 0; dim < t_dims; ++dim)
672 if (vec_a[dim] != vec_b[dim])
693 template<u
int01 t_dims,
class t_type>
696 return (((value.template as<t_dims, fltp08>() /
cast<fltp08>(d) + 0.5).template as<t_dims, sint08>()).template as<t_dims, fltp08>() *
cast<fltp08>(d)).template as<t_dims, t_type>();
714 template<u
int01 t_dims,
class t_type>
717 return (((value.template as<t_dims, fltp08>()
718 / d.template as<t_dims, fltp08>() + 0.5).template as<t_dims, uint08>()).template as<t_dims, fltp08>()
719 * d.template as<t_dims, fltp08>()).template as<t_dims, t_type>();
732 template<u
int01 t_dims,
class t_type>
733 struct Constant<Vector<t_dims, t_type>>
743 template<u
int01 t_dims,
class t_type>
744 static constexpr bool IsInvalid(
const Vector<t_dims, t_type>& value)
746 for (
uint01 dim = 0; dim < t_dims; ++dim)
754 template <
template <u
int01 t_dims,
class t_type>
class base,
typename derived>
757 template<u
int01 t_dims,
class t_type>
758 static constexpr std::true_type
test(
const base<t_dims, t_type>*);
759 static constexpr std::false_type
test(...);
760 using type =
decltype(
test(std::declval<derived*>()));
763 template <
template <u
int01 t_dims,
class t_type>
class base,
typename derived>
766 template<
class t_type>
771 template<
class t_type_a,
class t_type_b>
774 static constexpr bool value =
false;
776 template<
class t_type_a>
781 template<
class t_type_a,
class t_type_b>
785 template<class t = t_type_a, std::enable_if_t<!IsVec<t>::value,
int> = 0>
786 static constexpr bool internalValue()
790 template<class t = t_type_a, std::enable_if_t<IsVec<t>::value,
int> = 0>
791 static constexpr bool internalValue()
796 static constexpr bool value = internalValue();
802 struct hash<
NDEVR::Vector<2, NDEVR::uint04>>
806 std::size_t h = 0, g = 0;
810 h = (h << 4) + bytes[i];
820 struct hash<
NDEVR::Vector<3, NDEVR::uint04>>
824 std::size_t h = 0, g = 0;
828 h = (h << 4) + bytes[i];
838 struct hash<
NDEVR::Vector<3, NDEVR::fltp08>>
842 std::size_t h = 0, g = 0;
846 h = (h << 4) + bytes[i];
856 struct hash<
NDEVR::Vector<3, NDEVR::fltp04>>
860 std::size_t h = 0, g = 0;
864 h = (h << 4) + bytes[i];
#define lib_assert(expression, message)
Definition LibAssert.h:61
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
constexpr t_magnitude_type magnitude() const
Definition Vector.hpp:448
constexpr Vector() noexcept
Definition Vector.hpp:62
constexpr Vector< t_dims, t_type > operator-() const
Definition Vector.hpp:549
constexpr Vector(const Vector< tdims - 1, t_type > &vector, typename std::enable_if< tdims >=2, const t_type & >::type suffix)
Definition Vector.hpp:210
constexpr uint01 dimensionalIndex() const
Definition Vector.hpp:370
constexpr Vector(const t_type &x, const t_type &y, const typename std::enable_if< tdims==3, const t_type & >::type z)
Definition Vector.hpp:135
constexpr Vector(const t_type &prefix_a, const t_type &prefix_b, typename std::enable_if< tdims >=3, const Vector< tdims - 1, t_type > & >::type vector)
Definition Vector.hpp:276
constexpr t_type sum() const
Definition Vector.hpp:505
constexpr t_type product() const
Definition Vector.hpp:488
constexpr Vector(const t_type &x, const t_type &y, const t_type &z, const t_type &w, const t_type &v, const t_type &u, const t_type &t, const t_type &s, typename std::enable_if< tdims==9, const t_type & >::type r)
Definition Vector.hpp:176
constexpr const t_type & operator[](const uint01 dimension_index) const
Definition Vector.hpp:534
static constexpr t_type Type()
Definition Vector.hpp:619
constexpr Vector(const t_type(&vector)[t_dims])
Definition Vector.hpp:191
constexpr Vector(const t_type &x, const t_type &y, const t_type &z, typename std::enable_if< tdims==4, const t_type & >::type w)
Definition Vector.hpp:156
constexpr t_type dimensionalValue() const
Definition Vector.hpp:340
constexpr Vector(const t_type &x, const t_type &y, const t_type &z, const t_type &w, typename std::enable_if< tdims==5, const t_type & >::type v)
Definition Vector.hpp:163
constexpr Vector(const t_type &x, typename std::enable_if< tdims==2, const t_type & >::type y)
Definition Vector.hpp:115
constexpr Vector(const Vector< getMax(tdims - 2, 0), t_type > &vector, const t_type &suffix_a, typename std::enable_if< tdims >=3, const t_type & >::type suffix_b)
Definition Vector.hpp:233
constexpr Vector< t_dims, t_norm_type > normalized(Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::Invalid) const
Definition Vector.hpp:464
static constexpr uint01 NumberOfDimensions()
Definition Vector.hpp:607
constexpr t_type & operator[](uint01 dimension_index)
Definition Vector.hpp:526
constexpr Vector(const t_type &scaler) noexcept
Definition Vector.hpp:95
constexpr Vector< t_new_dim, t_new_type > as(t_new_type extra_fill_value) const
Definition Vector.hpp:317
constexpr t_type magnitudeSquared() const
Definition Vector.hpp:426
constexpr Vector(const t_type &x, const t_type &y, const t_type &z, const t_type &w, const t_type &v, typename std::enable_if< tdims==6, const t_type & >::type u)
Definition Vector.hpp:170
constexpr Vector(const Vector< t_dims, t_vec_type > &vector) noexcept
Definition Vector.hpp:77
constexpr Vector< t_dims, t_type > & operator=(const t_type &scaler)
Definition Vector.hpp:590
constexpr Vector< t_new_dim, t_new_type > as() const
Definition Vector.hpp:308
t_type m_values[t_dims]
Definition Vector.hpp:623
constexpr Vector(const t_type &prefix, typename std::enable_if< tdims >=2, const Vector< t_dims - 1, t_type > & >::type vector)
Definition Vector.hpp:255
constexpr Vector< t_dims, t_new_type > as() const
Definition Vector.hpp:300
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
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
@ MAX
Definition BaseValues.hpp:197
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:668
constexpr Vector< t_dims, Angle< t_angle_type > > quantize(const Vector< t_dims, Angle< t_angle_type > > &value, Angle< t_angle_type > d=Angle< t_angle_type >(DEGREES, 1.0))
Definition AngleFunctions.h:828
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
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
typename is_base_of_template_impl< base, derived >::type is_base_of_template
Definition Vector.hpp:764
@ Y
Definition BaseValues.hpp:169
@ X
Definition BaseValues.hpp:167
@ Z
Definition BaseValues.hpp:171
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
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
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
static const t_type Invalid
Definition BaseValues.hpp:234
static const t_type Min
Definition BaseValues.hpp:235
static const t_type Max
Definition BaseValues.hpp:236
Definition Vector.hpp:773
static constexpr bool value
Definition Vector.hpp:774
Definition Vector.hpp:768
static constexpr bool value
Definition Vector.hpp:769
Definition Vector.hpp:783
static constexpr bool value
Definition Vector.hpp:796
Definition Vector.hpp:756
decltype(test(std::declval< derived * >())) type
Definition Vector.hpp:760
static constexpr std::true_type test(const base< t_dims, t_type > *)
static constexpr std::false_type test(...)