20 #include "../util/c99defs.h" 36 static inline void vec2_zero(
struct vec2 *dst)
42 static inline void vec2_set(
struct vec2 *dst,
float x,
float y)
48 static inline void vec2_copy(
struct vec2 *dst,
const struct vec2 *v)
54 static inline void vec2_add(
struct vec2 *dst,
const struct vec2 *v1,
55 const struct vec2 *v2)
57 vec2_set(dst, v1->
x + v2->
x, v1->
y + v2->
y);
60 static inline void vec2_sub(
struct vec2 *dst,
const struct vec2 *v1,
61 const struct vec2 *v2)
63 vec2_set(dst, v1->
x - v2->
x, v1->
y - v2->
y);
66 static inline void vec2_mul(
struct vec2 *dst,
const struct vec2 *v1,
67 const struct vec2 *v2)
69 vec2_set(dst, v1->
x * v2->
x, v1->
y * v2->
y);
72 static inline void vec2_div(
struct vec2 *dst,
const struct vec2 *v1,
73 const struct vec2 *v2)
75 vec2_set(dst, v1->
x / v2->
x, v1->
y / v2->
y);
78 static inline void vec2_addf(
struct vec2 *dst,
const struct vec2 *v,
float f)
80 vec2_set(dst, v->
x + f, v->
y + f);
83 static inline void vec2_subf(
struct vec2 *dst,
const struct vec2 *v,
float f)
85 vec2_set(dst, v->
x - f, v->
y - f);
88 static inline void vec2_mulf(
struct vec2 *dst,
const struct vec2 *v,
float f)
90 vec2_set(dst, v->
x * f, v->
y * f);
93 static inline void vec2_divf(
struct vec2 *dst,
const struct vec2 *v,
float f)
95 vec2_set(dst, v->
x / f, v->
y / f);
98 static inline void vec2_neg(
struct vec2 *dst,
const struct vec2 *v)
100 vec2_set(dst, -v->
x, -v->
y);
103 static inline float vec2_dot(
const struct vec2 *v1,
const struct vec2 *v2)
105 return v1->
x * v2->
x + v1->
y * v2->
y;
108 static inline float vec2_len(
const struct vec2 *v)
110 return sqrtf(v->
x * v->
x + v->
y * v->
y);
113 static inline float vec2_dist(
const struct vec2 *v1,
const struct vec2 *v2)
116 vec2_sub(&temp, v1, v2);
117 return vec2_len(&temp);
120 static inline void vec2_minf(
struct vec2 *dst,
const struct vec2 *v,
float val)
128 static inline void vec2_min(
struct vec2 *dst,
const struct vec2 *v,
129 const struct vec2 *min_v)
137 static inline void vec2_maxf(
struct vec2 *dst,
const struct vec2 *v,
float val)
145 static inline void vec2_max(
struct vec2 *dst,
const struct vec2 *v,
146 const struct vec2 *max_v)
EXPORT void vec2_floor(struct vec2 *dst, const struct vec2 *v)
float ptr[2]
Definition: vec2.h:32
EXPORT int vec2_close(const struct vec2 *v1, const struct vec2 *v2, float epsilon)
#define EXPORT
Definition: c99defs.h:37
EXPORT void vec2_norm(struct vec2 *dst, const struct vec2 *v)
float y
Definition: vec2.h:30
EXPORT void vec2_ceil(struct vec2 *dst, const struct vec2 *v)
EXPORT void vec2_abs(struct vec2 *dst, const struct vec2 *v)
float x
Definition: vec2.h:30