28 #include <initializer_list> 29 #include <type_traits> 31 #include "Portability.h" 34 #ifndef DOXYGEN_SHOULD_SKIP_THIS 59 template<
typename T, std::
size_t N>
61 #ifndef DOXYGEN_SHOULD_SKIP_THIS 62 static_assert(
N > 0,
"N must be strictly positive");
88 std::fill_n(data,
N, val);
106 std::copy_n(array,
N, data);
124 std::copy_n(list.begin(), std::min(list.size(),
N), data);
146 static_assert(std::is_convertible<U,T>::value,
"");
297 template <
typename T>
321 std::fill_n(data, 2, val);
339 std::copy_n(array, 2, data);
529 template <
typename T>
553 std::fill_n(data, 3, val);
571 std::copy_n(array, 3, data);
594 : data{ xy.
x, xy.
y, z }
767 template <
typename T>
791 std::fill_n(data, 4, val);
809 std::copy_n(array, 4, data);
1181 template<
typename T, std::
size_t N>
1190 template<
typename T>
1199 template<
typename T>
1202 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1207 #endif // GAME_VECTOR_H Vector(T *array)
Constructor that takes an array.
Definition: Vector.h:569
Vector< T, 2 > xy
Swizzle to get the first two coordinates as a 2D vector.
Definition: Vector.h:726
T x
First coordinate in the (x,y) representation.
Definition: Vector.h:470
T g
Second coordinate in the (r,g,b) representation.
Definition: Vector.h:723
Vector(T val)
Constructor that fills the vector with a value.
Definition: Vector.h:552
const T * cbegin() const
Iterator.on the first element (const version).
Definition: Vector.h:925
const T * cend() const
Iterator on the element after the last one (const version).
Definition: Vector.h:935
T & operator[](std::size_t i)
Access to the -th coordinate.
Definition: Vector.h:650
Vector< T, 2 > xy
Swizzle to get the first two coordinates as a 2D vector.
Definition: Vector.h:956
const T * end() const
Iterator on the element after the last one (const version).
Definition: Vector.h:688
Distance< T, 2 > Distance2
A distance function for 2D vectors.
Definition: Vector.h:1191
constexpr Vector2f transform(const Matrix3f &mat, Vector2f point)
Apply an affine transformation to a 2D point.
Definition: Transform.h:331
T z
Third coordinate in the (x,y,z,w) representation.
Definition: Vector.h:947
T * end()
Iterator to the element after the last one.
Definition: Vector.h:203
const T * cend() const
Iterator on the element after the last one (const version).
Definition: Vector.h:707
T operator[](std::size_t i) const
Access to the -th coordinate.
Definition: Vector.h:169
T operator[](std::size_t i) const
Access to the -th coordinate.
Definition: Vector.h:863
constexpr Vector(T x, T y)
Constructor that takes 2 components.
Definition: Vector.h:348
T * begin()
Iterator.to the first element.
Definition: Vector.h:194
T a
Fourth coordinate in the (r,g,b,a) representation.
Definition: Vector.h:954
T * begin()
Iterator.to the first element.
Definition: Vector.h:660
T v
Second coordinate in the (u,v) representation.
Definition: Vector.h:475
T y
Second coordinate in the (x,y) representation.
Definition: Vector.h:471
T x
First coordinate in the (x,y,z) representation.
Definition: Vector.h:717
const T * begin() const
Iterator.to the first element (const version).
Definition: Vector.h:432
T width
First coordinate in the size representation.
Definition: Vector.h:482
const T * end() const
Iterator on the element after the last one (const version).
Definition: Vector.h:916
T s
First coordinate in the (s,t) representation.
Definition: Vector.h:478
T & operator[](std::size_t i)
Access to the -th coordinate.
Definition: Vector.h:878
constexpr Vector(T x, T y, T z)
Constructor that takes 3 components.
Definition: Vector.h:581
T data[N]
The internal representation of the vector.
Definition: Vector.h:251
const T * cend() const
Iterator on the element after the last one (const version).
Definition: Vector.h:460
T height
Second coordinate in the size representation.
Definition: Vector.h:483
T * end()
Iterator to the element after the last one.
Definition: Vector.h:669
constexpr Vector(T x, T y, T z, T w)
Constructor that takes 4 components.
Definition: Vector.h:820
const T * end() const
Iterator on the element after the last one (const version).
Definition: Vector.h:442
Distance< T, 3 > Distance3
A distance function for 3D vectors.
Definition: Vector.h:1200
Vector< T, 3 > xyz
Swizzle to get the first three coordinates as a 3D vector.
Definition: Vector.h:957
Vector< T, 3 > rgb
Swizzle to get the first three coordinates as a RGB color.
Definition: Vector.h:958
The namespace for gf classes.
Definition: Action.h:34
T operator[](std::size_t i) const
Access to the -th coordinate.
Definition: Vector.h:635
T g
Second coordinate in the (r,g,b,a) representation.
Definition: Vector.h:952
T x
First coordinate in the (x,y,z,w) representation.
Definition: Vector.h:945
T & operator[](std::size_t i)
Access to the -th coordinate.
Definition: Vector.h:184
T r
First coordinate in the (r,g,b) representation.
Definition: Vector.h:722
const T * cend() const
Iterator on the element after the last one (const version).
Definition: Vector.h:240
const T * cbegin() const
Iterator.on the first element (const version).
Definition: Vector.h:450
T b
Third coordinate in the (r,g,b,a) representation.
Definition: Vector.h:953
T & operator[](std::size_t i)
Access to the -th coordinate.
Definition: Vector.h:404
T col
First coordinate in the indices representation.
Definition: Vector.h:486
const T * cbegin() const
Iterator.on the first element (const version).
Definition: Vector.h:697
const T * begin() const
Iterator.to the first element (const version).
Definition: Vector.h:906
Vector(T *array)
Constructor that takes an array.
Definition: Vector.h:807
T * end()
Iterator to the element after the last one.
Definition: Vector.h:897
A 2D vector.
Definition: Vector.h:298
constexpr Vector(Vector< T, 2 > xy, T z)
Constructor that takes a 2D vector and a z component.
Definition: Vector.h:593
Vector(T *array)
Constructor that takes an array.
Definition: Vector.h:337
T operator[](std::size_t i) const
Access to the -th coordinate.
Definition: Vector.h:389
T y
Second coordinate in the (x,y,z) representation.
Definition: Vector.h:718
Vector(const Vector< U, 3 > &other)
Converting copy constructor.
Definition: Vector.h:616
const T * end() const
Iterator on the element after the last one (const version).
Definition: Vector.h:222
T y
Second coordinate in the (x,y,z,w) representation.
Definition: Vector.h:946
Vector(const Vector< U, 4 > &other)
Converting copy constructor.
Definition: Vector.h:843
T u
First coordinate in the (u,v) representation.
Definition: Vector.h:474
Vector(const Vector< U, N > &other)
Converting copy constructor.
Definition: Vector.h:144
T b
Third coordinate in the (r,g,b) representation.
Definition: Vector.h:724
const T * cbegin() const
Iterator.on the first element (const version).
Definition: Vector.h:230
T * begin()
Iterator.to the first element.
Definition: Vector.h:414
A 3D vector.
Definition: Vector.h:530
T r
First coordinate in the (r,g,b,a) representation.
Definition: Vector.h:951
General purpose math vector.
Definition: Vector.h:60
Vector(T val)
Constructor that fills the vector with a value.
Definition: Vector.h:86
T w
Fourth coordinate in the (x,y,z,w) representation.
Definition: Vector.h:948
const T * begin() const
Iterator.to the first element (const version).
Definition: Vector.h:678
T z
Third coordinate in the (x,y,z) representation.
Definition: Vector.h:719
T(*)(Vector< T, N >, Vector< T, N >) Distance
A distance function.
Definition: Vector.h:1182
Vector(std::initializer_list< T > list)
Constructor that takes an initializer list.
Definition: Vector.h:122
const T * begin() const
Iterator.to the first element (const version).
Definition: Vector.h:212
Vector(const Vector< U, 2 > &other)
Converting copy constructor.
Definition: Vector.h:371
T t
Second coordinate in the (s,t) representation.
Definition: Vector.h:479
Vector(T val)
Constructor that fills the vector with a value.
Definition: Vector.h:320
T * begin()
Iterator.to the first element.
Definition: Vector.h:888
T row
Second coordinate in the indices representation.
Definition: Vector.h:487
Vector(T *array)
Constructor that takes an array.
Definition: Vector.h:104
T * end()
Iterator to the element after the last one.
Definition: Vector.h:423
Vector(T val)
Constructor that fills the vector with a value.
Definition: Vector.h:790