|
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 | |
| 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 T scalar) const |
| Modulo the Vec2 object by a scalar. | |
| 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. | |
| Vec2 & | operator%= (const T scalar) |
| Modulo assignment operator for the Vec2 class. | |
| bool | operator== (const Vec2 &other) const =default |
| Equality 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 21 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 32 of file geometry.h.
|
inline |
Calculate the angle of the vector.
Definition at line 51 of file geometry.h.
Get angle of two vectors.
Definition at line 42 of file geometry.h.
Calculate the cross product of two vectors.
| other | The vector to cross with. |
Definition at line 83 of file geometry.h.
Get distance between two vectors.
Definition at line 63 of file geometry.h.
Calculate the dot product of two vectors.
| other | The vector to dot with. |
Definition at line 73 of file geometry.h.
|
inline |
Calculate the magnitude of the vector.
Definition at line 92 of file geometry.h.
Modulo the Vec2 object by a scalar.
| scalar | The scalar to modulo by |
Definition at line 142 of file geometry.h.
Modulo assignment operator for the Vec2 class.
| scalar | The scalar to modulo by. |
Definition at line 200 of file geometry.h.
Multiplication operator for the Vec2 class.
| scalar | The scalar to multiply by. |
Definition at line 122 of file geometry.h.
Multiplication assignment operator for the Vec2 class.
| scalar | The scalar to multiply by. |
Definition at line 176 of file geometry.h.
Addition operator for the Vec2 class.
| other | The vector to add. |
Definition at line 102 of file geometry.h.
Addition assignment operator for the Vec2 class.
| other | The vector to add. |
Definition at line 152 of file geometry.h.
Subtraction operator for the Vec2 class.
| other | The vector to subtract. |
Definition at line 112 of file geometry.h.
Subtraction assignment operator for the Vec2 class.
| other | The vector to subtract. |
Definition at line 164 of file geometry.h.
Division operator for the Vec2 class.
| scalar | The scalar to divide by. |
Definition at line 132 of file geometry.h.
Division assignment operator for the Vec2 class.
| scalar | The scalar to divide by. |
Definition at line 188 of file geometry.h.
Equality operator for the Vec2 class.
| other | The vector to compare. |
| T asw::Vec2< T >::x { 0 } |
The x component of the vector.
Definition at line 215 of file geometry.h.
| T asw::Vec2< T >::y { 0 } |
The y component of the vector.
Definition at line 218 of file geometry.h.