![]() |
Gamedev Framework (gf)
0.6.0
A C++11 framework for 2D games
|
A 4D vector. More...
#include <gf/Vector.h>
Public Member Functions | |
| Vector ()=default | |
| Default constructor. More... | |
| Vector (T val) | |
| Constructor that fills the vector with a value. More... | |
| Vector (T *array) | |
| Constructor that takes an array. More... | |
| constexpr | Vector (T x, T y, T z, T w) |
| Constructor that takes 4 components. More... | |
| Vector (const Vector &other)=default | |
| Default copy constructor. More... | |
| template<typename U > | |
| Vector (const Vector< U, 4 > &other) | |
| Converting copy constructor. More... | |
| T | operator[] (std::size_t i) const |
| Access to the \( i \)-th coordinate. More... | |
| 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... | |
Public Attributes | |
| union gf::Vector< T, 4 >:: { ... } | |
| T | data [4] |
| Generic representation. More... | |
| T | x |
First coordinate in the (x,y,z,w) representation. More... | |
| T | y |
Second coordinate in the (x,y,z,w) representation. More... | |
| T | z |
Third coordinate in the (x,y,z,w) representation. More... | |
| T | w |
Fourth coordinate in the (x,y,z,w) representation. More... | |
| T | r |
First coordinate in the (r,g,b,a) representation. More... | |
| T | g |
Second coordinate in the (r,g,b,a) representation. More... | |
| T | b |
Third coordinate in the (r,g,b,a) representation. More... | |
| T | a |
Fourth coordinate in the (r,g,b,a) representation. More... | |
| Vector< T, 2 > | xy |
| Swizzle to get the first two coordinates as a 2D vector. More... | |
| Vector< T, 3 > | xyz |
| Swizzle to get the first three coordinates as a 3D vector. More... | |
| Vector< T, 3 > | rgb |
| Swizzle to get the first three coordinates as a RGB color. More... | |
A 4D vector.
This specialization of gf::Vector handles the 4-dimension spaces. It can be accessed with various representations:
data member(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 Tunsigned as Tstd::size_t as Tfloat as Tdouble as Tbool as TFor colors, some additional typedef are defined:
float as Tuint8_t as TUsage example:
|
default |
Default constructor.
This constructor is defaulted so that this type is trivial.
|
inlineexplicit |
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 |
|
inlineexplicit |
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 |
Constructor that takes 4 components.
| x | The first component |
| y | The second component |
| z | The third component |
| w | The fourth component |
|
default |
Default copy constructor.
This constructor is defaulted so that this type is trivial.
| other | The vector to copy from |
|
inline |
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).
|
inline |
Access to the \( i \)-th coordinate.
| i | the coordinate number |
|
inline |
Access to the \( i \)-th coordinate.
| i | the coordinate number |
| union { ... } |
An anonymous union to handle the various representations
| T gf::Vector< T, 4 >::a |
| T gf::Vector< T, 4 >::b |
| T gf::Vector< T, 4 >::data[4] |
Generic representation.
| T gf::Vector< T, 4 >::g |
| T gf::Vector< T, 4 >::r |
| Vector<T, 3> gf::Vector< T, 4 >::rgb |
Swizzle to get the first three coordinates as a RGB color.
| T gf::Vector< T, 4 >::w |
| T gf::Vector< T, 4 >::x |
| Vector<T, 2> gf::Vector< T, 4 >::xy |
Swizzle to get the first two coordinates as a 2D vector.
| Vector<T, 3> gf::Vector< T, 4 >::xyz |
Swizzle to get the first three coordinates as a 3D vector.
| T gf::Vector< T, 4 >::y |
1.8.13