33#include <NDEVR/BaseValues.h>
34#include <NDEVR/LibAssert.h>
60 template<u
int01 t_dims,
class t_type>
80 template<
class t_vec_type>
84 for (
uint01 dim = 0; dim < t_dims; ++dim)
101 constexpr explicit Vector(
const t_type& scaler) noexcept
104 for(
uint01 dim = 0; dim < t_dims; ++dim)
122 template<u
int01 tdims = t_dims>
123 constexpr Vector(
const t_type& x,
typename std::enable_if<tdims == 2, const t_type&>::type y)
126 static_assert(t_dims == 2,
"Unexpected Number of Dimensions. Vector Size Required: 2");
144 template<u
int01 tdims = t_dims>
145 constexpr Vector(
const t_type& x,
const t_type& y,
const typename std::enable_if<tdims == 3, const t_type&>::type z)
148 static_assert(t_dims == 3,
"Unexpected Number of Dimensions. Vector Size Required: 3");
167 template<u
int01 tdims = t_dims>
168 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)
171 static_assert(t_dims == 4,
"Unexpected Number of Dimensions. Vector Size Required: 4");
174 template<u
int01 tdims = t_dims>
175 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)
178 static_assert(t_dims == 5,
"Unexpected Number of Dimensions. Vector Size Required: 5");
181 template<u
int01 tdims = t_dims>
182 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)
185 static_assert(t_dims == 6,
"Unexpected Number of Dimensions. Vector Size Required: 6");
187 template<u
int01 tdims = t_dims>
188 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)
189 :
m_values{ x, y, z, w, v, u, t, s, r }
191 static_assert(t_dims == 9,
"Unexpected Number of Dimensions. Vector Size Required: 9");
205 constexpr explicit Vector(
const t_type(&vector)[t_dims])
208 for (
uint01 dim = 0; dim < t_dims; dim++)
225 template<u
int01 tdims = t_dims>
229 static_assert(t_dims >= 2,
"Unexpected Number of Dimensions. Vector Size Required: >= 2");
230 for(
uint01 dim = 0; dim < t_dims - 1; ++dim)
250 template<u
int01 tdims = t_dims>
251 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)
254 static_assert(t_dims >= 3,
"Unexpected Number of Dimensions. Vector Size Required: >= 3");
255 for(
uint01 dim = 0; dim < t_dims - 2; ++dim)
274 template<u
int01 tdims = t_dims>
278 static_assert(t_dims >= 2,
"Unexpected Number of Dimensions. Vector Size Required: >= 2");
280 for(
uint01 dim =
Y; dim < t_dims; ++dim)
297 template<u
int01 tdims = t_dims>
301 static_assert(t_dims >= 3,
"Unexpected Number of Dimensions. Vector Size Required: >= 3");
304 for (
uint01 dim =
Z; dim < t_dims; ++dim)
323 template<
class t_new_type>
327 for (
uint01 dim = 0; dim < t_dims; ++dim)
331 template<u
int01 t_new_dim,
class t_new_type>
336 for (
uint01 dim = 0; dim < min; ++dim)
340 template<u
int01 t_new_dim,
class t_new_type>
346 for(; dim < min; dim++)
348 for(; dim < t_new_dim; dim++)
349 vec[dim] = extra_fill_value;
365 template<LocationValues t_max_min>
369 for(
uint01 dim = 1; dim < t_dims; ++dim)
371 if constexpr(t_max_min ==
MAX)
397 template<LocationValues t_max_min>
401 for(
uint01 dim = 1; dim < t_dims; ++dim)
403 if constexpr (t_max_min ==
MAX)
429 template<
uint01 tdims = t_dims
430 ,
typename =
typename std::enable_if<tdims == 1>::type>
431 constexpr operator t_type&()
436 template<
uint01 tdims = t_dims
437 ,
typename =
typename std::enable_if<tdims == 1>::type>
438 constexpr operator const t_type &()
const
461 for(
uint01 dim = 0; dim < t_dims; ++dim)
481 template<
class t_magnitude_type = t_type>
499 template<
class t_norm_type = t_type>
507 for (
uint01 dim = 0; dim < t_dims; dim++)
526 [[nodiscard]]
constexpr t_type
product()
const
529 for(
uint01 dim = 1; dim < t_dims; ++dim)
545 [[nodiscard]]
constexpr t_type
sum()
const
548 for (
uint01 dim = 1; dim < t_dims; ++dim)
570 lib_assert(dimension_index < t_dims,
"Dimension requested Exceeded maximum vector dimension");
578 lib_assert(dimension_index < t_dims,
"Dimension requested Exceeded maximum vector dimension");
596 for(
uint01 dim = 0; dim < t_dims; ++dim)
640 for (
uint01 dim = 0; dim < t_dims; ++dim)
671 constexpr static t_type
Type() {
return t_type(); }
696 template<u
int01 t_dims,
class t_type>
699 for (
uint01 dim = 0; dim < t_dims; ++dim)
701 if (vec_a[dim] != vec_b[dim])
723 template<u
int01 t_dims,
class t_type>
726 for (
uint01 dim = 0; dim < t_dims; ++dim)
728 if (vec_a[dim] != vec_b[dim])
751 template<u
int01 t_dims,
class t_type>
754 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>();
774 template<u
int01 t_dims,
class t_type>
777 return (((value.template as<t_dims, fltp08>()
778 / d.template as<t_dims, fltp08>() + 0.5).template as<t_dims, uint08>()).template as<t_dims, fltp08>()
779 * d.template as<t_dims, fltp08>()).template as<t_dims, t_type>();
792 template<u
int01 t_dims,
class t_type>
803 template<u
int01 t_dims,
class t_type>
804 static constexpr bool isNaN(
const Vector<t_dims, t_type>& value)
806 for (
uint01 dim = 0; dim < t_dims; ++dim)
808 if (isNaN(value[dim]))
814 template <
template <u
int01 t_dims,
class t_type>
class base,
typename derived>
817 template<u
int01 t_dims,
class t_type>
818 static constexpr std::true_type
test(
const base<t_dims, t_type>*);
819 static constexpr std::false_type
test(...);
820 using type =
decltype(
test(std::declval<derived*>()));
823 template <
template <u
int01 t_dims,
class t_type>
class base,
typename derived>
826 template<
class t_type>
831 template<
class t_type_a,
class t_type_b>
834 static constexpr bool value =
false;
836 template<
class t_type_a>
841 template<
class t_type_a,
class t_type_b>
844 template<class t = t_type_a, std::enable_if_t<!IsVec<t>::value,
int> = 0>
849 template<class t = t_type_a, std::enable_if_t<IsVec<t>::value,
int> = 0>
861 struct hash<
NDEVR::Vector<2, NDEVR::uint04>>
865 std::size_t h = 0, g = 0;
869 h = (h << 4) + bytes[i];
879 struct hash<
NDEVR::Vector<3, NDEVR::uint04>>
883 std::size_t h = 0, g = 0;
887 h = (h << 4) + bytes[i];
897 struct hash<
NDEVR::Vector<3, NDEVR::fltp08>>
901 std::size_t h = 0, g = 0;
905 h = (h << 4) + bytes[i];
915 struct hash<
NDEVR::Vector<3, NDEVR::fltp04>>
919 std::size_t h = 0, g = 0;
923 h = (h << 4) + bytes[i];
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
constexpr t_magnitude_type magnitude() const
Definition Vector.hpp:482
constexpr Vector() noexcept
Definition Vector.hpp:64
constexpr Vector< t_dims, t_type > operator-() const
Definition Vector.hpp:593
constexpr Vector(const Vector< tdims - 1, t_type > &vector, typename std::enable_if< tdims >=2, const t_type & >::type suffix)
Definition Vector.hpp:226
constexpr uint01 dimensionalIndex() const
Definition Vector.hpp:398
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:145
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:298
constexpr t_type sum() const
Definition Vector.hpp:545
constexpr t_type product() const
Definition Vector.hpp:526
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:188
constexpr const t_type & operator[](const uint01 dimension_index) const
Definition Vector.hpp:576
static constexpr t_type Type()
Definition Vector.hpp:671
constexpr Vector(const t_type(&vector)[t_dims])
Definition Vector.hpp:205
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:168
constexpr t_type dimensionalValue() const
Definition Vector.hpp:366
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:175
constexpr Vector(const t_type &x, typename std::enable_if< tdims==2, const t_type & >::type y)
Definition Vector.hpp:123
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:251
static constexpr uint01 NumberOfDimensions()
Definition Vector.hpp:657
constexpr t_type & operator[](uint01 dimension_index)
Definition Vector.hpp:568
constexpr Vector(const t_type &scaler) noexcept
Definition Vector.hpp:101
constexpr Vector< t_new_dim, t_new_type > as(t_new_type extra_fill_value) const
Definition Vector.hpp:341
constexpr t_type magnitudeSquared() const
Definition Vector.hpp:458
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:182
constexpr Vector(const Vector< t_dims, t_vec_type > &vector) noexcept
Definition Vector.hpp:81
constexpr Vector< t_dims, t_type > & operator=(const t_type &scaler)
Definition Vector.hpp:638
constexpr Vector< t_new_dim, t_new_type > as() const
Definition Vector.hpp:332
t_type m_values[t_dims]
Definition Vector.hpp:675
constexpr Vector< t_dims, t_norm_type > normalized(Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::NaN) const
Definition Vector.hpp:500
constexpr Vector(const t_type &prefix, typename std::enable_if< tdims >=2, const Vector< t_dims - 1, t_type > & >::type vector)
Definition Vector.hpp:275
constexpr Vector< t_dims, t_new_type > as() const
Definition Vector.hpp:324
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
@ MAX
Definition BaseValues.hpp:227
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:724
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:955
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
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
typename is_base_of_template_impl< base, derived >::type is_base_of_template
Definition Vector.hpp:824
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
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
Definition BaseValues.hpp:272
static const t_type Min
Definition BaseValues.hpp:276
static const t_type Max
Definition BaseValues.hpp:278
static const t_type NaN
Definition BaseValues.hpp:274
Definition Vector.hpp:833
static constexpr bool value
Definition Vector.hpp:834
Definition Vector.hpp:828
static constexpr bool value
Definition Vector.hpp:829
Definition Vector.hpp:843
static constexpr bool value
Definition Vector.hpp:855
static constexpr bool _value()
Definition Vector.hpp:845
Definition Vector.hpp:816
decltype(test(std::declval< derived * >())) type
Definition Vector.hpp:820
static constexpr std::true_type test(const base< t_dims, t_type > *)
static constexpr std::false_type test(...)
std::size_t operator()(const NDEVR::Vector< 2, NDEVR::uint04 > &s) const noexcept
Definition Vector.hpp:863
std::size_t operator()(const NDEVR::Vector< 3, NDEVR::fltp04 > &s) const noexcept
Definition Vector.hpp:917
std::size_t operator()(const NDEVR::Vector< 3, NDEVR::fltp08 > &s) const noexcept
Definition Vector.hpp:899
std::size_t operator()(const NDEVR::Vector< 3, NDEVR::uint04 > &s) const noexcept
Definition Vector.hpp:881