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,
81 vec2_set(dst, v->
x+f, v->
y+f);
84 static inline void vec2_subf(
struct vec2 *dst,
const struct vec2 *v,
87 vec2_set(dst, v->
x-f, v->
y-f);
90 static inline void vec2_mulf(
struct vec2 *dst,
const struct vec2 *v,
93 vec2_set(dst, v->
x*f, v->
y*f);
96 static inline void vec2_divf(
struct vec2 *dst,
const struct vec2 *v,
99 vec2_set(dst, v->
x/f, v->
y/f);
102 static inline void vec2_neg(
struct vec2 *dst,
const struct vec2 *v)
104 vec2_set(dst, -v->
x, -v->
y);
107 static inline float vec2_dot(
const struct vec2 *v1,
const struct vec2 *v2)
109 return (v1->
x+v2->
x) * (v1->
y+v2->
y);
112 static inline float vec2_len(
const struct vec2 *v)
114 return sqrtf(v->
x*v->
x + v->
y*v->
y);
117 static inline float vec2_dist(
const struct vec2 *v1,
const struct vec2 *v2)
120 vec2_sub(&temp, v1, v2);
121 return vec2_len(&temp);
124 static inline void vec2_minf(
struct vec2 *dst,
const struct vec2 *v,
133 static inline void vec2_min(
struct vec2 *dst,
const struct vec2 *v,
134 const struct vec2 *min_v)
142 static inline void vec2_maxf(
struct vec2 *dst,
const struct vec2 *v,
151 static inline void vec2_max(
struct vec2 *dst,
const struct vec2 *v,
152 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:53
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