crisp-game-lib-portable
vector.h
Go to the documentation of this file.
1
2#ifndef VECTOR_H
3#define VECTOR_H
4
5#ifdef __cplusplus
6#define EXTERNC extern "C"
7#else
8#define EXTERNC extern
9#endif
10
11typedef struct {
12 float x;
13 float y;
14} Vector;
15
16EXTERNC Vector* vectorSet(Vector* vec, float x, float y);
17EXTERNC Vector* vectorAdd(Vector* vec, float x, float y);
18EXTERNC Vector* vectorMul(Vector* vec, float v);
19EXTERNC Vector* rotate(Vector* vec, float angle);
20EXTERNC Vector* addWithAngle(Vector* vec, float angle, float length);
21EXTERNC float angleTo(Vector* vec, float x, float y);
22EXTERNC float distanceTo(Vector* vec, float x, float y);
23EXTERNC float vectorAngle(Vector* vec);
24EXTERNC float vectorLength(Vector* vec);
26
28#define VEC_XY(v) v.x, v.y
29
30#endif
Vector * vectorSet(Vector *vec, float x, float y)
Definition: vector.c:5
Vector * rotate(Vector *vec, float angle)
Definition: vector.c:23
Vector * vectorAdd(Vector *vec, float x, float y)
Definition: vector.c:11
Vector * addWithAngle(Vector *vec, float angle, float length)
Definition: vector.c:30
float distanceTo(Vector *vec, float x, float y)
Definition: vector.c:40
Vector * vectorMul(Vector *vec, float v)
Definition: vector.c:17
float vectorLength(Vector *vec)
Definition: vector.c:48
float vectorAngle(Vector *vec)
Definition: vector.c:46
float angleTo(Vector *vec, float x, float y)
Definition: vector.c:36