Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
vector2d.c File Reference

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.
 

Function Documentation

◆ addVec2d()

vec_t addVec2d ( vec_t left,
vec_t right )

Add two vectors and return the resulting vector.

Parameters
leftOne vector to add
rightThe other vector to add
Returns
The sum of both vectors

◆ subVec2d()

vec_t subVec2d ( vec_t left,
vec_t right )

Subtract two vectors and return the resulting vector.

Parameters
leftThe vector to subtract from
rightThe other vector to subtract
Returns
The difference between the vectors

◆ mulVec2d()

vec_t mulVec2d ( vec_t vector,
int32_t scalar )

Multiply a vector by a scalar and return the result.

Parameters
vectorThe vector to multiply
scalarThe scalar to multiply by
Returns
The multiplied vector

◆ divVec2d()

vec_t divVec2d ( vec_t vector,
int32_t scalar )

Divide a vector by a scalar and return the result.

Parameters
vectorThe vector to divide
scalarThe scalar to divide by
Returns
The divided vector

◆ dotVec2d()

int32_t dotVec2d ( vec_t left,
vec_t right )

Find the dot product of two vectors.

Parameters
leftOne vector to dot
rightThe other vector to dot
Returns
The dot product of the two vectors

◆ rotateVec2d()

vec_t rotateVec2d ( vec_t vector,
int32_t degree )

Rotate a vector by a number of degrees and return the result.

Parameters
vectorThe vector to rotate
degreeThe angle to rotate clockwise by, in degrees
Returns
The rotated vector

◆ sqMagVec2d()

int32_t sqMagVec2d ( vec_t vector)

Return the squared magnitude of the given vector. The square root is not used because it is slow.

Parameters
vectorThe vector to get the squared magnitude for
Returns
The squared magnitude of the vector