![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A 4D vector. More...
#include <gf/Vector.h>
Public Member Functions | |
Vector ()=default | |
Default constructor. More... | |
constexpr | Vector (ZeroType) noexcept |
Constructor that zero the vector out. More... | |
constexpr | Vector (T val) noexcept |
Constructor that fills the vector with a value. More... | |
constexpr | Vector (const T *array) |
Constructor that takes an array. More... | |
constexpr | Vector (T first, T second, T third, T fourth) noexcept |
Constructor that takes 4 components. More... | |
Vector (const Vector &other)=default | |
Default copy constructor. More... | |
template<typename U > | |
Vector (const Vector< U, 4 > &other) noexcept | |
Converting copy constructor. More... | |
Vector & | operator= (const Vector &other)=default |
Default copy assignment. More... | |
constexpr T | operator[] (std::size_t i) const |
Access to the \( i \)-th coordinate. More... | |
constexpr T & | operator[] (std::size_t i) |
Access to the \( i \)-th coordinate. More... | |
T * | begin () |
Iterator.to the first element. More... | |
T * | end () |
Iterator to the element after the last one. More... | |
const T * | begin () const |
Iterator.to the first element (const version). More... | |
const T * | end () const |
Iterator on the element after the last one (const version). More... | |
const T * | cbegin () const |
Iterator.on the first element (const version). More... | |
const T * | cend () const |
Iterator on the element after the last one (const version). More... | |
constexpr void | zero () noexcept |
Zero out the vector. More... | |
constexpr Vector< T, 2 > | xy () const |
Swizzle to get the first two coordinates as a 2D vector. More... | |
constexpr Vector< T, 3 > | xyz () const |
Swizzle to get the first three coordinates as a 3D vector. More... | |
constexpr Vector< T, 3 > | rgb () const |
Swizzle to get the first three coordinates as a RGB color. More... | |
Public Attributes | |
union gf::Vector< T, 4 >:: { ... } | |
union gf::Vector< T, 4 >:: { ... } | |
union gf::Vector< T, 4 >:: { ... } | |
union gf::Vector< T, 4 >:: { ... } | |
T | x |
First coordinate in the (x,y,z,w) representation. More... | |
T | r |
First coordinate in the (r,g,b,a) representation. More... | |
T | y |
Second coordinate in the (x,y,z,w) representation. More... | |
T | g |
Second coordinate in the (r,g,b,a) representation. More... | |
T | z |
Third coordinate in the (x,y,z,w) representation. More... | |
T | b |
Third coordinate in the (r,g,b,a) representation. More... | |
T | w |
Fourth coordinate in the (x,y,z,w) representation. More... | |
T | a |
Fourth coordinate in the (r,g,b,a) representation. More... | |
A 4D vector.
This specialization of gf::Vector handles the 4-dimension spaces. It can be accessed with various representations:
(x,y,z,w)
representation, used for generic coordinates in the 4D space(r,g,b,a)
representation, used for RGBA colorsSeveral common typedef are defined:
int
as T
unsigned
as T
std::size_t
as T
float
as T
double
as T
bool
as T
For colors, some additional typedef are defined:
float
as T
uint8_t
as T
Usage example:
|
default |
Default constructor.
This constructor is defaulted so that this type is trivial.
|
inlineconstexprnoexcept |
Constructor that zero the vector out.
|
inlineexplicitconstexprnoexcept |
Constructor that fills the vector with a value.
This constructor takes a value and fills the entire vector with this value. Care must be taken when calling this constructor:
val | The value to fill the vector with |
|
inlineexplicitconstexpr |
Constructor that takes an array.
This constructor can ease conversion from other math libraries. The array must contain enough data for 4 dimensions.
array | An array with the values of the vector |
|
inlineconstexprnoexcept |
Constructor that takes 4 components.
first | The first component |
second | The second component |
third | The third component |
fourth | The fourth component |
|
default |
Default copy constructor.
This constructor is defaulted so that this type is trivial.
other | The vector to copy from |
|
inlinenoexcept |
Converting copy constructor.
other | The vector to copy from |
|
inline |
Iterator.to the first element.
|
inline |
Iterator.to the first element (const version).
|
inline |
Iterator.on the first element (const version).
|
inline |
Iterator on the element after the last one (const version).
|
inline |
Iterator to the element after the last one.
|
inline |
Iterator on the element after the last one (const version).
|
default |
Default copy assignment.
This operator is defaulted so that this type is trivial.
|
inlineconstexpr |
Access to the \( i \)-th coordinate.
i | the coordinate number |
|
inlineconstexpr |
Access to the \( i \)-th coordinate.
i | the coordinate number |
|
inlineconstexpr |
Swizzle to get the first three coordinates as a RGB color.
|
inlineconstexpr |
Swizzle to get the first two coordinates as a 2D vector.
|
inlineconstexpr |
Swizzle to get the first three coordinates as a 3D vector.
|
inlineconstexprnoexcept |
Zero out the vector.
union gf::Vector< T, 4 > { ... } gf::Vector< T, 4 >::@77 |
An anonymous union to handle the first coordinate
union gf::Vector< T, 4 > { ... } gf::Vector< T, 4 >::@79 |
An anonymous union to handle the second coordinate
union gf::Vector< T, 4 > { ... } gf::Vector< T, 4 >::@81 |
An anonymous union to handle the third coordinate
union gf::Vector< T, 4 > { ... } gf::Vector< T, 4 >::@83 |
An anonymous union to handle the fourth coordinate
T gf::Vector< T, 4 >::a |
T gf::Vector< T, 4 >::b |
T gf::Vector< T, 4 >::g |
T gf::Vector< T, 4 >::r |
T gf::Vector< T, 4 >::w |
T gf::Vector< T, 4 >::x |
T gf::Vector< T, 4 >::y |
T gf::Vector< T, 4 >::z |