]> git.bts.cx Git - benzene.git/blob - src/bz/math/vector.h
Initial version
[benzene.git] / src / bz / math / vector.h
1 #ifndef BZ_MATH_VECTOR_H
2 #define BZ_MATH_VECTOR_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 struct BZVector {
9 float x;
10 float y;
11 };
12 typedef struct BZVector BZVector;
13
14 static inline BZVector *bzVectorSet(BZVector *vectorOut, float x, float y) {
15 vectorOut->x = x;
16 vectorOut->y = y;
17 return vectorOut;
18 }
19
20 extern void bzVectorCopy(BZVector *vectorOut, const BZVector *vector);
21
22 static inline BZVector bzVectorMake(float x, float y) {
23 BZVector v = {
24 .x = x,
25 .y = y,
26 };
27 return v;
28 }
29
30 extern void bzVectorMakeAngle(BZVector *vectorOut, float angle);
31
32 extern void bzVectorInverse(BZVector *vectorOut, const BZVector *vector);
33 extern void bzVectorTangent(BZVector *vectorOut, const BZVector *vector);
34
35 extern void bzVectorAdd(BZVector *vectorOut, const BZVector *vector1, const BZVector *vector2);
36 extern void bzVectorSubtract(BZVector *vectorOut, const BZVector *vector1, const BZVector *vector2);
37
38 extern void bzVectorScale(BZVector *vectorOut, const BZVector *vector, float scale);
39 extern void bzVectorNormalized(BZVector *vectorOut, const BZVector *vector);
40
41 extern float bzVectorMagnitude(const BZVector *vector);
42 extern float bzVectorMagnitudeSquared(const BZVector *vector);
43 extern float bzVectorDot(const BZVector *vector1, const BZVector *vector2);
44
45 extern float bzVectorCross(const BZVector *vector1, const BZVector *vector2);
46
47 extern void bzVectorLerp(BZVector *vectorOut, const BZVector *vector1, const BZVector *vector2, float t);
48
49 #ifdef __cplusplus
50 }
51 #endif
52
53 #endif