14#pragma warning(disable : 4201)
22 template <Primitive T>
25 static_assert(!std::is_const_v<T>);
29 static constexpr size_t size = 3;
31 constexpr vec() =
default;
38 template <Primitive U>
39 constexpr vec(U value);
50 template <Primitive A, Primitive B, Primitive C>
51 constexpr vec(A a, B b, C c);
58 template <
typename... U>
61 constexpr vec(std::array<T, size>
const &arr) :
data{ arr } {}
63 constexpr vec(std::array<T, size> &&arr) :
data{
std::move(arr) } {}
67 constexpr void reset() noexcept;
71 constexpr
vec<
size, T> &operator=(_detail::rvec<
size, U> const &b)
73 for (
size_t i = 0; i <
size; i++)
71 constexpr
vec<
size, T> &operator=(_detail::rvec<
size, U> const &b) {
…}
83 for (
size_t i = 0; i <
size; i++)
93 [[nodiscard]] constexpr
vec<3, T> operator-() const noexcept;
96 constexpr
vec<3, T> &operator+=(U const value) noexcept;
98 constexpr
vec<3, T> &operator-=(U const value) noexcept;
100 constexpr
vec<3, T> &operator*=(U const value) noexcept;
102 constexpr
vec<3, T> &operator/=(U const value) noexcept;
104 constexpr
vec<3, T> &operator%=(U const value) noexcept;
106 constexpr
vec<3, T> &operator+=(U const &other) noexcept requires(
size == U::
size);
108 constexpr
vec<3, T> &operator-=(U const &other) noexcept requires(
size == U::
size);
110 constexpr
vec<3, T> &operator*=(U const &other) noexcept requires(
size == U::
size);
112 constexpr
vec<3, T> &operator/=(U const &other) noexcept requires(
size == U::
size);
114 constexpr
vec<3, T> &operator%=(U const &other) noexcept requires(
size == U::
size);
117 [[nodiscard]] constexpr T &operator[](
size_t i);
119 [[nodiscard]] constexpr T const &operator[](
size_t i) const;
146 static_assert(
sizeof(
data) == 3 *
sizeof(T));
154 template <Primitive _>
168 template <
typename A,
typename B,
typename... C>
178 template <Primitive U>
196 template <
typename A,
typename B,
typename... C>
197 constexpr void unpack_data(
size_t offset, A a, B b, C... c);
209 template <Primitive T, Primitive U>
Concept to determine if a type is any kind of vector.
Concept that ensures a type is either floating point or integral.
Contains mathematical utility functions and classes.
constexpr mat< T::size.x, T::size.y, std::remove_const_t< typename T::type > > operator+(U const left, T const &right)
Adds a matrix to a primitive.
constexpr vec< 3, T > cross(qua< T > const &left, vec< 3, U > const &right) noexcept
Cross product between quaternion and vector.
T type
Type of the vector elements.
static constexpr vec< 3, T > zero() noexcept
Returns a zero vector.
constexpr vec(std::array< T, size > const &arr)
Constructor from std::array.
constexpr vec(std::array< T, size > &&arr)
Move constructor from std::array.
constexpr void unpack_data(size_t offset, V vec)
Unpacks a vector into the matrix data.
constexpr vec()=default
Default constructor.
constexpr vec< size, T > & operator=(vec< size, U > const &b)
Overloaded assignment operator for another vec object.
static constexpr size_t get_parameter_pack_size()
Determines the size of a parameter pack for vector types.
Definition of the mathematical vector with fixed size L and type T
std::array< T, size > data
The underlying data of the vector.
static constexpr size_t get_parameter_pack_size()
Determines the size of a parameter pack for primitive types.
constexpr void unpack_data(size_t offset, U u)
Unpacks a single primitive value into the vector data.
static constexpr size_t size
Number of elements in the vector.
constexpr vec()=default
Default constructor.
constexpr void reset() noexcept
Resets the vector to the zero vector.