MathFu
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups Pages
mathfu::VectorPacked< T, d > Class Template Reference

Packed N-dimensional vector. More...

#include "mathfu/vector.h"

Detailed Description

template<class T, int d>
class mathfu::VectorPacked< T, d >

Packed N-dimensional vector.

Some Vector classes are padded so that it's possible to use the data structures with SIMD instructions. This structure can be used in conjunction with unpacked Vector classes to pack data into flat arrays suitable for sending to a GPU (e.g vertex buffers).

For example, to pack (store) an unpacked to packed vector:

VectorPacked<float, 3> packed;
Vector<float, 3> vector(3, 2, 1);
vector.Pack(&packed);

or

Vector<float, 3> vector(3, 2, 1);
VectorPacked<float, 3> packed = vector;

To initialize a vector from a packed vector:

VectorPacked<float, 3> packed = { 3, 2, 1 };
Vector<float, 3> vector(packed);

Template Parameters
Ttype of VectorPacked elements.
ddimensions (number of elements) in the VectorPacked structure.

Public Member Functions

 VectorPacked ()
 Create an uninitialized VectorPacked.
 
 VectorPacked (const Vector< T, d > &vector)
 
VectorPackedoperator= (const Vector< T, d > &vector)
 

Public Attributes

data [d]
 Elements of the packed vector one per dimension.
 

Constructor & Destructor Documentation

template<class T, int d>
mathfu::VectorPacked< T, d >::VectorPacked ( const Vector< T, d > &  vector)
inlineexplicit

Create a VectorPacked from a Vector.

Both VectorPacked and Vector must have the same number of dimensions.

Parameters
vectorVector to create the VectorPacked from.

Member Function Documentation

template<class T, int d>
VectorPacked& mathfu::VectorPacked< T, d >::operator= ( const Vector< T, d > &  vector)
inline

Copy a Vector to a VectorPacked.

Both VectorPacked and Vector must have the same number of dimensions.

Parameters
vectorVector to copy to the VectorPacked.
Returns
A reference to this VectorPacked.

The documentation for this class was generated from the following file: