#include <AH/Math/Vector.hpp>
Type for 2D vectors of floating point numbers.
Vec2fs can be added, subtracted, multiplied (dot product) and normalized. It also has an implementation of the following operators: "+", "+=", "-", "-=", "*" (vector-vector); "*", "*=", "/", "/=" (vector-scalar); "==", "!=" (equality); "*" (scalar-vector); "<<" (printing).
Definition at line 42 of file Vector.hpp.
Public Member Functions | |
Vec2f ()=default | |
Create a vector that is initialized to the zero vector (0,0). More... | |
Vec2f (float x, float y) | |
Create a vector with the given x and y coordinates. More... | |
Vec2f & | operator+= (Vec2f rhs) |
Addition. More... | |
Vec2f | operator+ (Vec2f rhs) const |
Addition. More... | |
Vec2f | operator- () const |
Negation. More... | |
Vec2f & | operator-= (Vec2f rhs) |
Subtraction. More... | |
Vec2f | operator- (Vec2f rhs) const |
Subtraction. More... | |
Vec2f & | operator*= (float rhs) |
Scalar multiplication. More... | |
Vec2f | operator* (float rhs) const |
Scalar multiplication. More... | |
Vec2f & | operator/= (float rhs) |
Scalar division. More... | |
Vec2f | operator/ (float rhs) const |
Scalar division. More... | |
float | operator* (Vec2f rhs) const |
Inner product. More... | |
float | normSquared () const |
Norm squared. More... | |
float | norm () const |
Norm. More... | |
Vec2f & | normalize () |
Normalize this vector. More... | |
Vec2f | normalized () const |
Normalize a copy of this vector (doesn't change the original vector). More... | |
bool | operator== (Vec2f rhs) const |
Equality check. More... | |
bool | operator!= (Vec2f rhs) const |
Inequality check. More... | |
Public Attributes | |
float | x = 0.0 |
The x component of the vector. More... | |
float | y = 0.0 |
The y component of the vector. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Print & | operator<< (Print &os, Vec2f v) |
Printing. More... | |
Vec2f | operator* (float lhs, Vec2f rhs) |
Scalar multiplication. More... | |
Print & | operator<< (Print &os, Vec2f v) |
Printing. More... | |
|
default |
Create a vector that is initialized to the zero vector (0,0).
|
inline |
Create a vector with the given x and y coordinates.
Definition at line 49 of file Vector.hpp.
Addition.
Definition at line 52 of file Vector.hpp.
Addition.
Definition at line 58 of file Vector.hpp.
|
inline |
Negation.
Definition at line 65 of file Vector.hpp.
Subtraction.
Definition at line 67 of file Vector.hpp.
Subtraction.
Definition at line 69 of file Vector.hpp.
|
inline |
Scalar multiplication.
Definition at line 76 of file Vector.hpp.
|
inline |
Scalar multiplication.
Definition at line 82 of file Vector.hpp.
|
inline |
Scalar division.
Definition at line 89 of file Vector.hpp.
|
inline |
Scalar division.
Definition at line 95 of file Vector.hpp.
|
inline |
Inner product.
Definition at line 102 of file Vector.hpp.
|
inline |
Norm squared.
Definition at line 107 of file Vector.hpp.
|
inline |
Norm.
Definition at line 109 of file Vector.hpp.
|
inline |
Normalize this vector.
Definition at line 114 of file Vector.hpp.
|
inline |
Normalize a copy of this vector (doesn't change the original vector).
Definition at line 116 of file Vector.hpp.
|
inline |
Equality check.
Definition at line 119 of file Vector.hpp.
|
inline |
Inequality check.
Definition at line 123 of file Vector.hpp.
|
related |
Printing.
Definition at line 32 of file Vector.cpp.
float x = 0.0 |
The x component of the vector.
Definition at line 43 of file Vector.hpp.
float y = 0.0 |
The y component of the vector.
Definition at line 44 of file Vector.hpp.