|
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 3D vector in space. More...
#include <geometry.h>
Public Types | |
| using | Real = std::conditional_t<std::is_floating_point_v<T>, T, float> |
| Type used for lengths and angles. Integer vectors use float so results are not truncated. | |
Public Member Functions | |
| Vec3 ()=default | |
| Default constructor for the Vec3 class. | |
| Vec3 (T x, T y, T z) | |
| Constructor for the Vec3 class. | |
| Real | angle (const Vec3 &other) const |
| Get angle between two vectors (in 3D space). | |
| Real | distance (const Vec3 &other) const |
| Get distance between two vectors. | |
| T | dot (const Vec3 &other) const |
| Calculate the dot product of two vectors. | |
| Vec3 | cross (const Vec3 &other) const |
| Calculate the cross product of two vectors. | |
| Real | magnitude () const |
| Calculate the magnitude of the vector. | |
| Vec3 | operator+ (const Vec3 &other) const |
| Addition operator for the Vec3 class. | |
| Vec3 | operator- (const Vec3 &other) const |
| Subtraction operator for the Vec3 class. | |
| Vec3 | operator* (const T scalar) const |
| Multiplication operator for the Vec3 class. | |
| Vec3 | operator/ (const T scalar) const |
| Division operator for the Vec3 class. | |
| Vec3 | operator% (const T scalar) const |
| Modulo the Vec3 object by a scalar. | |
| Vec3 & | operator+= (const Vec3 &other) |
| Addition assignment operator for the Vec3 class. | |
| Vec3 & | operator-= (const Vec3 &other) |
| Subtraction assignment operator for the Vec3 class. | |
| Vec3 & | operator*= (const T scalar) |
| Multiplication assignment operator for the Vec3 class. | |
| Vec3 & | operator/= (const T scalar) |
| Division assignment operator for the Vec3 class. | |
| Vec3 & | operator%= (const T scalar) |
| Modulo assignment operator for the Vec3 class. | |
| bool | operator== (const Vec3 &other) const =default |
| Equality operator for the Vec3 class. | |
Public Attributes | |
| T | x { 0 } |
| The x component of the vector. | |
| T | y { 0 } |
| The y component of the vector. | |
| T | z { 0 } |
| The z component of the vector. | |
A 3D vector in space.
This class represents a 3D vector in space. It is used to represent points, directions, and sizes.
Definition at line 288 of file geometry.h.
| using asw::Vec3< T >::Real = std::conditional_t<std::is_floating_point_v<T>, T, float> |
Type used for lengths and angles. Integer vectors use float so results are not truncated.
Definition at line 292 of file geometry.h.
|
inline |
Constructor for the Vec3 class.
| x | The x component of the vector. |
| y | The y component of the vector. |
| z | The z component of the vector. |
Definition at line 304 of file geometry.h.
Get angle between two vectors (in 3D space).
Definition at line 315 of file geometry.h.
Calculate the cross product of two vectors.
| other | The vector to cross with. |
Definition at line 352 of file geometry.h.
Get distance between two vectors.
Definition at line 331 of file geometry.h.
Calculate the dot product of two vectors.
| other | The vector to dot with. |
Definition at line 342 of file geometry.h.
Calculate the magnitude of the vector.
Definition at line 362 of file geometry.h.
Modulo the Vec3 object by a scalar.
| scalar | The scalar to modulo by |
Definition at line 412 of file geometry.h.
Modulo assignment operator for the Vec3 class.
| scalar | The scalar to modulo by. |
Definition at line 474 of file geometry.h.
Multiplication operator for the Vec3 class.
| scalar | The scalar to multiply by. |
Definition at line 392 of file geometry.h.
Multiplication assignment operator for the Vec3 class.
| scalar | The scalar to multiply by. |
Definition at line 448 of file geometry.h.
Addition operator for the Vec3 class.
| other | The vector to add. |
Definition at line 372 of file geometry.h.
Addition assignment operator for the Vec3 class.
| other | The vector to add. |
Definition at line 422 of file geometry.h.
Subtraction operator for the Vec3 class.
| other | The vector to subtract. |
Definition at line 382 of file geometry.h.
Subtraction assignment operator for the Vec3 class.
| other | The vector to subtract. |
Definition at line 435 of file geometry.h.
Division operator for the Vec3 class.
| scalar | The scalar to divide by. |
Definition at line 402 of file geometry.h.
Division assignment operator for the Vec3 class.
| scalar | The scalar to divide by. |
Definition at line 461 of file geometry.h.
Equality operator for the Vec3 class.
| other | The vector to compare. |
| T asw::Vec3< T >::x { 0 } |
The x component of the vector.
Definition at line 490 of file geometry.h.
| T asw::Vec3< T >::y { 0 } |
The y component of the vector.
Definition at line 493 of file geometry.h.
| T asw::Vec3< T >::z { 0 } |
The z component of the vector.
Definition at line 496 of file geometry.h.