EBGeometry 1.0
|
Two-dimensional vector class with arithmetic operators. More...
#include <EBGeometry_Vec.hpp>
Public Member Functions | |
Vec2T () | |
Default constructor. Sets the vector to the zero vector. | |
Vec2T (const Vec2T &u) noexcept | |
Copy constructor. | |
constexpr | Vec2T (const T &a_x, const T &a_y) |
Full constructor. | |
~Vec2T ()=default | |
Destructor (does nothing) | |
constexpr Vec2T< T > & | operator= (const Vec2T &a_other) noexcept |
Assignment operator. Sets this.x = a_other.x and this.y = a_other.y. | |
constexpr Vec2T< T > | operator+ (const Vec2T &a_other) const noexcept |
Addition operator. | |
constexpr Vec2T< T > | operator- (const Vec2T &a_other) const noexcept |
Subtraction operator. | |
constexpr Vec2T< T > | operator- () const noexcept |
Negation operator. Returns a new Vec2T<T> with negated components. | |
constexpr Vec2T< T > | operator* (const T &s) const noexcept |
Multiplication operator. | |
constexpr Vec2T< T > | operator/ (const T &s) const noexcept |
Division operator. | |
constexpr Vec2T< T > & | operator+= (const Vec2T &a_other) noexcept |
Addition operator. | |
constexpr Vec2T< T > & | operator-= (const Vec2T &a_other) noexcept |
Subtraction operator. | |
constexpr Vec2T< T > & | operator*= (const T &s) noexcept |
Multiplication operator. | |
constexpr Vec2T< T > & | operator/= (const T &s) noexcept |
Division operator operator. | |
constexpr T | dot (const Vec2T &a_other) const noexcept |
Dot product operator. | |
constexpr T | length () const noexcept |
Compute length of vector. | |
constexpr T | length2 () const noexcept |
Compute square of vector. | |
Static Public Member Functions | |
static constexpr Vec2T< T > | zero () noexcept |
Return av vector with x = y = 0. | |
static constexpr Vec2T< T > | one () noexcept |
Return av vector with x = y = 1. | |
static constexpr Vec2T< T > | min () noexcept |
Return minimum possible representative vector. | |
static constexpr Vec2T< T > | max () noexcept |
Return maximum possible representative vector. | |
static constexpr Vec2T< T > | infinity () noexcept |
Return a vector with inf components. | |
Public Attributes | |
T | x |
First component in the vector. | |
T | y |
Second component in the vector. | |
Two-dimensional vector class with arithmetic operators.
The class has a public-only interface. To change it's components one can call the member functions, or set components directly, e.g. vec.x = 5.0
Copy constructor.
[in] | u | Other vector |
Sets *this = u
Full constructor.
[in] | a_x | First vector component |
[in] | a_y | Second vector component |
Sets this->x = a_x and this->y = a_y
Dot product operator.
[in] | a_other | other vector |
Returns the dot product, i.e. this->x*a_other.x + this->y+a_other.y
Compute length of vector.
Compute square of vector.
Multiplication operator.
[in] | s | Scalar to be multiplied |
Returns a new Vec2T<T> with components x = s*this->x (and same for y)
Multiplication operator.
[in] | s | Scalar to multiply by |
Returns (*this) with components this->x = s*this->x (and same for y)
|
inlineconstexprnoexcept |
Addition operator.
[in] | a_other | Other vector |
Returns a new object with component x = this->x + a_other.x (same for y-component)
Addition operator.
[in] | a_other | Other vector to add |
Returns (*this) with components this->x = this->x + a_other.x (and same for y)
|
inlineconstexprnoexcept |
Subtraction operator.
[in] | a_other | Other vector |
Returns a new object with component x = this->x - a_other.x (same for y-component)
Subtraction operator.
[in] | a_other | Other vector to subtract |
Returns (*this) with components this->x = this->x - a_other.x (and same for y)
Division operator.
[in] | s | Scalar to be multiplied |
Returns a new Vec2T<T> with components x = (1/s)*this->x (and same for y)
Division operator operator.
[in] | s | Scalar to divide by |
Returns (*this) with components this->x = (1/s)*this->x (and same for y)
Assignment operator. Sets this.x = a_other.x and this.y = a_other.y.
[in] | a_other | Other vector |