Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
vector2d.h
Go to the documentation of this file.
1
28#ifndef _VECTOR_2D_H_
29#define _VECTOR_2D_H_
30
31#include <stdint.h>
32
36typedef struct
37{
38 int32_t x;
39 int32_t y;
40} vec_t;
41
42vec_t addVec2d(vec_t left, vec_t right);
43vec_t subVec2d(vec_t left, vec_t right);
44vec_t mulVec2d(vec_t vector, int32_t scalar);
45vec_t divVec2d(vec_t vector, int32_t scalar);
46
47int32_t dotVec2d(vec_t left, vec_t right);
48vec_t rotateVec2d(vec_t vector, int32_t degree);
49int32_t sqMagVec2d(vec_t vector);
50
51#endif
int32_t dotVec2d(vec_t left, vec_t right)
Find the dot product of two vectors.
Definition vector2d.c:75
vec_t divVec2d(vec_t vector, int32_t scalar)
Divide a vector by a scalar and return the result.
Definition vector2d.c:59
vec_t subVec2d(vec_t left, vec_t right)
Subtract two vectors and return the resulting vector.
Definition vector2d.c:27
vec_t mulVec2d(vec_t vector, int32_t scalar)
Multiply a vector by a scalar and return the result.
Definition vector2d.c:43
int32_t sqMagVec2d(vec_t vector)
Return the squared magnitude of the given vector. The square root is not used because it is slow.
Definition vector2d.c:116
vec_t rotateVec2d(vec_t vector, int32_t degree)
Rotate a vector by a number of degrees and return the result.
Definition vector2d.c:87
vec_t addVec2d(vec_t left, vec_t right)
Add two vectors and return the resulting vector.
Definition vector2d.c:11
int32_t y
The signed integer Y component of the vector.
Definition vector2d.h:39
int32_t x
The signed integer X component of the vector.
Definition vector2d.h:38
A 2D vector with signed integer X and Y components.
Definition vector2d.h:37