Skip to content

LiteFX::Math::Vector

An algebraic vector type. The value type of a vector must be in standard layout (i.e., std::is_standard_layout_v<T> must evaluate to true). This constraint is enforced at compile time and ensures that vector types can be binary marshaled. For example, the LiteFX::Graphics::Vertex type stores nothing more than a series of vectors. The standard layout constraint ensures that a set of vertices can be converted into a plain byte array and back.

Synopsis

Declared in <litefx/vector.hpp>

template<
    typename T,
    unsigned int DIM>
requires (DIM > 0) && std::is_standard_layout_v<T> && std::is_trivially_copyable_v<T>
struct Vector;

Type Aliases

NameDescription
scalar_type The type of the vector elements.
vec_type The type of the vector itself.

Member Functions

NameDescription
Vector [constructor]Constructors
~Vector [destructor]Destroys the vector.
operator= Assignment operators
begin Returns an interator for that addresses the begin of the vector elements.
cbegin Returns a constant interator for that addresses the begin of the vector elements.
cend Returns a constant interator for that addresses the end of the vector elements.
elements Returns a pointer to the elements of the vector.
end Returns an interator for that addresses the end of the vector elements.
operator[] Subscript operators
size Returns the number of dimensions of the vector.
w w overloads
x x overloads
y y overloads
z z overloads
operator std::array<T, DIM> Converts the vector to an instance of std::array.
operator std::vector<T> Converts the vector into an instance of type std::vector.

Static Data Members

NameDescription
vec_size Stores the size of the vector.

Protected Type Aliases

Name
array_type

Protected Data Members

Name
m_elements

Template Parameters

NameDescription
TThe type of the vector scalar elements. Must be in standard layout (i.e., std::is_standard_layout_v<T> must evaluate to true).
DIMThe number of dimensions of the vector.

Derived Classes

NameDescription
Rect
RectF
RectI
Size2d
Size3d
Size4d
Vector1f A vector that contains a single float.
Vector1u A vector that contains a single unsigned integer.
Vector2f A vector that contains two floats.
Vector2i A vector that contains two signed integers.
Vector2u A vector that contains two unsigned integers.
Vector3f A vector that stores three floats.
Vector3i
Vector3u
Vector4f
Vector4i
Vector4u