![]() |
Gamedev Framework (gf)
0.6.0
A C++11 framework for 2D games
|
A 2D 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) |
| Constructor that takes 2 components. More... | |
| Vector (const Vector &other)=default | |
| Default copy constructor. More... | |
| template<typename U > | |
| Vector (const Vector< U, 2 > &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, 2 >:: { ... } | |
| T | data [2] |
| Generic representation. More... | |
| T | x |
First coordinate in the (x,y) representation. More... | |
| T | y |
Second coordinate in the (x,y) representation. More... | |
| T | u |
First coordinate in the (u,v) representation. More... | |
| T | v |
Second coordinate in the (u,v) representation. More... | |
| T | s |
First coordinate in the (s,t) representation. More... | |
| T | t |
Second coordinate in the (s,t) representation. More... | |
| T | width |
| First coordinate in the size representation. More... | |
| T | height |
| Second coordinate in the size representation. More... | |
| T | col |
| First coordinate in the indices representation. More... | |
| T | row |
| Second coordinate in the indices representation. More... | |
A 2D vector.
This specialization of gf::Vector handles the 2-dimension spaces. It can be accessed with various representations:
data member(x,y) representation, used for generic coordinates in the 2D space(u,v) representation, used for texture coordinates (see UV mapping)(s,t) representation, used for texture coordinateswidth member and a height member, used to represent a 2-dimensional sizecol member and a row member, used to access a 2-dimensional array (gf::Array2D)Several common typedef are defined:
int as Tunsigned as Tstd::size_t as Tfloat as Tdouble as Tbool 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 2 dimensions.
| array | An array with the values of the vector |
|
inline |
Constructor that takes 2 components.
| x | The first component |
| y | The second 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, 2 >::col |
First coordinate in the indices representation.
| T gf::Vector< T, 2 >::data[2] |
Generic representation.
| T gf::Vector< T, 2 >::height |
Second coordinate in the size representation.
| T gf::Vector< T, 2 >::row |
Second coordinate in the indices representation.
| T gf::Vector< T, 2 >::s |
First coordinate in the (s,t) representation.
| T gf::Vector< T, 2 >::t |
Second coordinate in the (s,t) representation.
| T gf::Vector< T, 2 >::u |
First coordinate in the (u,v) representation.
| T gf::Vector< T, 2 >::v |
Second coordinate in the (u,v) representation.
| T gf::Vector< T, 2 >::width |
First coordinate in the size representation.
| T gf::Vector< T, 2 >::x |
First coordinate in the (x,y) representation.
| T gf::Vector< T, 2 >::y |
Second coordinate in the (x,y) representation.
1.8.13