jtmm2/include/vec.h

35 lines
852 B
C

#ifndef _DEF_VEC
#define _DEF_VEC
typedef struct Vec
{
int x;
int y;
} Vec;
/* like memcpy but for vectors */
void vec_cpy(Vec *destination, Vec source);
/* 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);
/* multiply a vector by a scale */
void vec_mul(Vec *vector, int scale);
void vec_mulf(Vec *vector, float scale);
/* divise a vector by a scale */
void vec_div(Vec *vector, int scale);
void vec_divf(Vec *vector, float scale);
/* 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);
/* Draw a rectangle using two Vec as coordinates */
void vec_drect(Vec top_left, Vec bottom_right, int color);
#endif /* _DEF_VEC */