A vector is one of the most important data structure for games.
A N-dimensional vector contains N elements and can perform various tasks. The Vector class is templated with two parameters: A type parameter T and the dimension N. So Vector<float, 3> is a 3D vector with float elements.
You can have every vector you like, but in most cases you just need a small number of vector types. Those types have typename aliases for easy use:
There are a lot of other short names, for the complete list see: util/VectorCore.hpp
There are some different ways to create a Vector:
The last two methods come very handy when passing a Vector to a function, because its less to type ;)
You can access the elements of an vector in two ways: With a letter x, y, z, w (just for dimensions 2, 3 and 4) or via [] operator:
You can calculate with Vectors just like you would write on paper (thanks to the power of operator overloading):
If you want to multiply two vectors you have two possibilities:
The vector also has a lot of methods for manipuling it. Actually there often are pairs of methods: One method that manipulates the current object and one that returns a manipulated copy of the object. For example: normalize() changes the object (every component /= length) and normalized() returns the normalized vector instead of changing the object. For all methods see: lumina::Vector