Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
These utility functions are can be used for signed integer vector 2D math. Vector math is useful for physics calculations.
No initialization or deinitialization is required. Each function will return a new vector and will not modify the vectors given as arguments. See the functions below for what is provided and how to use them.
Go to the source code of this file.
Data Structures | |
struct | vec_t |
A 2D vector with signed integer X and Y components. More... | |
Functions | |
vec_t | addVec2d (vec_t left, vec_t right) |
Add two vectors and return the resulting vector. | |
vec_t | subVec2d (vec_t left, vec_t right) |
Subtract two vectors and return the resulting vector. | |
vec_t | mulVec2d (vec_t vector, int32_t scalar) |
Multiply a vector by a scalar and return the result. | |
vec_t | divVec2d (vec_t vector, int32_t scalar) |
Divide a vector by a scalar and return the result. | |
int32_t | dotVec2d (vec_t left, vec_t right) |
Find the dot product of two vectors. | |
vec_t | rotateVec2d (vec_t vector, int32_t degree) |
Rotate a vector by a number of degrees and return the result. | |
int32_t | sqMagVec2d (vec_t vector) |
Return the squared magnitude of the given vector. The square root is not used because it is slow. | |
struct vec_t |
Add two vectors and return the resulting vector.
left | One vector to add |
right | The other vector to add |
Subtract two vectors and return the resulting vector.
left | The vector to subtract from |
right | The other vector to subtract |
Multiply a vector by a scalar and return the result.
vector | The vector to multiply |
scalar | The scalar to multiply by |
Divide a vector by a scalar and return the result.
vector | The vector to divide |
scalar | The scalar to divide by |
Find the dot product of two vectors.
left | One vector to dot |
right | The other vector to dot |
Rotate a vector by a number of degrees and return the result.
vector | The vector to rotate |
degree | The angle to rotate clockwise by, in degrees |
int32_t sqMagVec2d | ( | vec_t | vector | ) |
Return the squared magnitude of the given vector. The square root is not used because it is slow.
vector | The vector to get the squared magnitude for |