ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
|
A 2D vector in space. More...
#include <geometry.h>
Public Member Functions | |
Vec2 () | |
Default constructor for the Vec2 class. | |
Vec2 (T x, T y) | |
Constructor for the Vec2 class. | |
T | angle (const Vec2 &other) const |
Get angle of two vectors. | |
T | angle () const |
Calculate the angle of the vector. | |
T | distance (const Vec2 &other) const |
Get distance between two vectors. | |
T | dot (const Vec2 &other) const |
Calculate the dot product of two vectors. | |
T | cross (const Vec2 &other) const |
Calculate the cross product of two vectors. | |
T | magnitude () const |
Calculate the magnitude of the vector. | |
Vec2 | operator+ (const Vec2 &other) const |
Addition operator for the Vec2 class. | |
Vec2 | operator- (const Vec2 &other) const |
Subtraction operator for the Vec2 class. | |
Vec2 | operator* (const T scalar) const |
Multiplication operator for the Vec2 class. | |
Vec2 | operator/ (const T scalar) const |
Division operator for the Vec2 class. | |
Vec2 & | operator+= (const Vec2 &other) |
Addition assignment operator for the Vec2 class. | |
Vec2 & | operator-= (const Vec2 &other) |
Subtraction assignment operator for the Vec2 class. | |
Vec2 & | operator*= (const T scalar) |
Multiplication assignment operator for the Vec2 class. | |
Vec2 & | operator/= (const T scalar) |
Division assignment operator for the Vec2 class. | |
bool | operator== (const Vec2 &other) const |
Equality operator for the Vec2 class. | |
bool | operator!= (const Vec2 &other) const |
Inequality operator for the Vec2 class. | |
Public Attributes | |
T | x {0} |
The x component of the vector. | |
T | y {0} |
The y component of the vector. | |
A 2D vector in space.
This class represents a 2D vector in space. It is used to represent points, directions, and sizes.
Definition at line 22 of file geometry.h.
|
inline |
Default constructor for the Vec2 class.
Definition at line 26 of file geometry.h.
|
inline |
Constructor for the Vec2 class.
x | The x component of the vector. |
y | The y component of the vector. |
Definition at line 33 of file geometry.h.
|
inline |
Calculate the angle of the vector.
Definition at line 47 of file geometry.h.
Get angle of two vectors.
Definition at line 39 of file geometry.h.
Calculate the cross product of two vectors.
other | The vector to cross with. |
Definition at line 74 of file geometry.h.
Get distance between two vectors.
Definition at line 58 of file geometry.h.
Calculate the dot product of two vectors.
other | The vector to dot with. |
Definition at line 67 of file geometry.h.
|
inline |
Calculate the magnitude of the vector.
Definition at line 80 of file geometry.h.
Inequality operator for the Vec2 class.
other | The vector to compare. |
Definition at line 176 of file geometry.h.
Multiplication operator for the Vec2 class.
scalar | The scalar to multiply by. |
Definition at line 105 of file geometry.h.
Multiplication assignment operator for the Vec2 class.
scalar | The scalar to multiply by. |
Definition at line 145 of file geometry.h.
Addition operator for the Vec2 class.
other | The vector to add. |
Definition at line 87 of file geometry.h.
Addition assignment operator for the Vec2 class.
other | The vector to add. |
Definition at line 123 of file geometry.h.
Subtraction operator for the Vec2 class.
other | The vector to subtract. |
Definition at line 96 of file geometry.h.
Subtraction assignment operator for the Vec2 class.
other | The vector to subtract. |
Definition at line 134 of file geometry.h.
Division operator for the Vec2 class.
scalar | The scalar to divide by. |
Definition at line 114 of file geometry.h.
Division assignment operator for the Vec2 class.
scalar | The scalar to divide by. |
Definition at line 156 of file geometry.h.
Equality operator for the Vec2 class.
other | The vector to compare. |
Definition at line 167 of file geometry.h.
T asw::Vec2< T >::x {0} |
The x component of the vector.
Definition at line 181 of file geometry.h.
T asw::Vec2< T >::y {0} |
The y component of the vector.
Definition at line 184 of file geometry.h.