Gamedev Framework (gf)
0.3.0
A C++11 framework for 2D games
|
A 3D 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) |
Constructor that takes 3 components. More... | |
constexpr | Vector (Vector< T, 2 > xy, T z) |
Constructor that takes a 2D vector and a z component. More... | |
Vector (const Vector &other)=default | |
Default copy constructor. More... | |
template<typename U > | |
Vector (const Vector< U, 3 > &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 (void) |
Iterator.to the first element. More... | |
T * | end (void) |
Iterator to the element after the last one. More... | |
T const * | begin (void) const |
Iterator.to the first element (const version). More... | |
T const * | end (void) const |
Iterator on the element after the last one (const version). More... | |
T const * | cbegin (void) const |
Iterator.on the first element (const version). More... | |
T const * | cend (void) const |
Iterator on the element after the last one (const version). More... | |
Public Attributes | |
union gf::Vector< T, 3 >:: { ... } | |
T | data [3] |
Generic representation. More... | |
T | x |
First coordinate in the (x,y,z) representation. More... | |
T | y |
Second coordinate in the (x,y,z) representation. More... | |
T | z |
Third coordinate in the (x,y,z) representation. More... | |
T | r |
First coordinate in the (r,g,b) representation. More... | |
T | g |
Second coordinate in the (r,g,b) representation. More... | |
T | b |
Third coordinate in the (r,g,b) representation. More... | |
Vector< T, 2 > | xy |
Swizzle to get the first two coordinates as a 2D vector. More... | |
A 3D vector.
This specialization of gf::Vector handles the 3-dimension spaces. It can be accessed with various representations:
data
member(x,y,z)
representation, used for generic coordinates in the 3D space(r,g,b)
representation, used for RGB 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.
|
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 3 dimensions.
array | An array with the values of the vector |
Constructor that takes 3 components.
x | The first component |
y | The second component |
z | The third component |
Constructor that takes a 2D vector and a z component.
xy | The first 2 component, x and y |
z | The z 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, 3 >::b |
T gf::Vector< T, 3 >::data[3] |
Generic representation.
T gf::Vector< T, 3 >::g |
T gf::Vector< T, 3 >::r |
T gf::Vector< T, 3 >::x |
Vector<T, 2> gf::Vector< T, 3 >::xy |
Swizzle to get the first two coordinates as a 2D vector.
T gf::Vector< T, 3 >::y |
T gf::Vector< T, 3 >::z |