#include <ellalgo/linear_algebra.hpp>
template<typename T>
Vector2 class
A simple 2D vector class for linear algebra operations.
| Template parameters | |
|---|---|
| T | The element type (typically float or double) |
This class provides basic vector operations including addition, subtraction, scalar multiplication, dot product, and norm calculation. It is implemented using std::vector as the underlying storage.
Constructors, destructors, conversion operators
Public functions
-
auto operator[](size_
t i) -> T& -
auto operator[](size_
t i) const -> const T& -
auto size() const -> size_
t - auto operator+=(const Vector2& rhs) -> Vector2&
- auto operator-=(const Vector2& rhs) -> Vector2&
- auto operator*=(T scalar) -> Vector2&
- auto dot(const Vector2& other) const -> T
- auto norm() const -> T
Function documentation
template<typename T>
T& Vector2<T>:: operator[](size_ t i)
| Parameters | |
|---|---|
| i | The index of the element to access. |
| Returns | A reference to the element at the specified index. |
Provides access to the elements of the Vector2 object.
template<typename T>
const T& Vector2<T>:: operator[](size_ t i) const
| Parameters | |
|---|---|
| i | The index of the element to access. |
| Returns | A constant reference to the element at the specified index. |
Provides constant access to the elements of the Vector2 object.