#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 39 of file Vector.hpp.
Public Member Functions | |
Vec2f ()=default | |
Create a vector that is initialized to the zero vector (0,0). | |
Vec2f (float x, float y) | |
Create a vector with the given x and y coordinates. | |
Vec2f & | operator+= (Vec2f rhs) |
Addition. | |
Vec2f | operator+ (Vec2f rhs) const |
Addition. | |
Vec2f | operator- () const |
Negation. | |
Vec2f & | operator-= (Vec2f rhs) |
Subtraction. | |
Vec2f | operator- (Vec2f rhs) const |
Subtraction. | |
Vec2f & | operator*= (float rhs) |
Scalar multiplication. | |
Vec2f | operator* (float rhs) const |
Scalar multiplication. | |
Vec2f & | operator/= (float rhs) |
Scalar division. | |
Vec2f | operator/ (float rhs) const |
Scalar division. | |
float | operator* (Vec2f rhs) const |
Inner product. | |
float | normSquared () const |
Norm squared. | |
float | norm () const |
Norm. | |
Vec2f & | normalize () |
Normalize this vector. | |
Vec2f | normalized () const |
Normalize a copy of this vector (doesn't change the original vector). | |
bool | operator== (Vec2f rhs) const |
Equality check. | |
bool | operator!= (Vec2f rhs) const |
Inequality check. | |
Public Attributes | |
float | x = 0.0 |
The x component of the vector. | |
float | y = 0.0 |
The y component of the vector. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Print & | operator<< (Print &os, Vec2f v) |
Printing. | |
Vec2f | operator* (float lhs, Vec2f rhs) |
Scalar multiplication. | |
Print & | operator<< (Print &os, Vec2f v) |
Printing. | |
|
default |
Create a vector that is initialized to the zero vector (0,0).
Create a vector with the given x and y coordinates.
Definition at line 46 of file Vector.hpp.
Addition.
Definition at line 49 of file Vector.hpp.
Addition.
Definition at line 55 of file Vector.hpp.
Negation.
Definition at line 62 of file Vector.hpp.
Subtraction.
Definition at line 64 of file Vector.hpp.
Subtraction.
Definition at line 66 of file Vector.hpp.
Scalar multiplication.
Definition at line 73 of file Vector.hpp.
Scalar multiplication.
Definition at line 79 of file Vector.hpp.
Scalar division.
Definition at line 86 of file Vector.hpp.
Scalar division.
Definition at line 92 of file Vector.hpp.
Inner product.
Definition at line 99 of file Vector.hpp.
|
inline |
Norm squared.
Definition at line 104 of file Vector.hpp.
|
inline |
Norm.
Definition at line 106 of file Vector.hpp.
|
inline |
Normalize this vector.
Definition at line 111 of file Vector.hpp.
|
inline |
Normalize a copy of this vector (doesn't change the original vector).
Definition at line 113 of file Vector.hpp.
Equality check.
Definition at line 116 of file Vector.hpp.
Inequality check.
Definition at line 120 of file Vector.hpp.
Printing.
Definition at line 30 of file Vector.cpp.
float x = 0.0 |
The x component of the vector.
Definition at line 40 of file Vector.hpp.
float y = 0.0 |
The y component of the vector.
Definition at line 41 of file Vector.hpp.