2020-09-11 12:01:24 +02:00
|
|
|
#ifndef _DEF_VEC
|
|
|
|
#define _DEF_VEC
|
2020-09-10 17:58:12 +02:00
|
|
|
|
|
|
|
typedef struct Vec
|
|
|
|
{
|
2020-09-18 11:12:34 +02:00
|
|
|
int x;
|
|
|
|
int y;
|
2020-09-10 17:58:12 +02:00
|
|
|
} Vec;
|
|
|
|
|
2020-09-12 10:08:01 +02:00
|
|
|
/* like memcpy but for vectors */
|
2020-09-14 10:33:01 +02:00
|
|
|
void vec_cpy(Vec *destination, Vec source);
|
2020-09-12 10:08:01 +02:00
|
|
|
|
2020-09-10 17:58:12 +02:00
|
|
|
/* apply a force on a vector */
|
|
|
|
void vec_add(Vec *vector, Vec force);
|
|
|
|
|
|
|
|
/* apply the opposite of a force on a vector */
|
|
|
|
void vec_sub(Vec *vector, Vec force);
|
|
|
|
|
2020-09-12 10:08:01 +02:00
|
|
|
/* multiply a vector by a scale */
|
2020-09-21 14:15:58 +02:00
|
|
|
void vec_mul(Vec *vector, int scale);
|
|
|
|
void vec_mulf(Vec *vector, float scale);
|
2020-09-12 10:08:01 +02:00
|
|
|
|
|
|
|
/* divise a vector by a scale */
|
2020-09-21 14:15:58 +02:00
|
|
|
void vec_div(Vec *vector, int scale);
|
|
|
|
void vec_divf(Vec *vector, float scale);
|
2020-09-12 10:08:01 +02:00
|
|
|
|
2020-09-14 10:33:01 +02:00
|
|
|
/* Linear interpolation between two vectors.
|
|
|
|
* Require a scale ranging from 0 to 1 (0 is instant, 1 is completly still). */
|
|
|
|
void vec_lerp(Vec *from, Vec to, float scale);
|
|
|
|
|
2020-09-21 14:15:58 +02:00
|
|
|
/* Draw a rectangle using two Vec as coordinates */
|
|
|
|
void vec_drect(Vec top_left, Vec bottom_right, int color);
|
|
|
|
|
2020-09-11 18:07:53 +02:00
|
|
|
#endif /* _DEF_VEC */
|