1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <math.h>
#include "math.h"
#include "../util/assert.h"
#include "../core/mem.h"
Vec4 vec4zero = { 0, 0, 0,0 };
static Vec4 sharedmat4;
void vec4_dividew(Vec4* v, Vec3* out) {
ssr_assert(out && v);
float w = 1.f / v->w;
out->x = v->x * w ;
out->y = v->y * w;
out->z = v->z * w;
}
void vec4_tostring(Vec4* v, char buf[]) {
sprintf(buf, "%8.3f %8.3f %8.3f %8.3f", v->x, v->y, v->z, v->w);
}
void vec4_print(Vec4* v) {
vec4_tostring(v, printbuffer);
printf("\n%s\n", printbuffer);
}
void vec4_lerp(Vec4* a, Vec4* b, float t, Vec4* out) {
out->x = lerp(a->x, b->x, t);
out->y = lerp(a->y, b->y, t);
out->z = lerp(a->z, b->z, t);
out->w = lerp(a->w, b->w, t);
}
void vec4_scale(Vec4* v, float t, Vec4* out) {
out->x = v->x * t;
out->y = v->y * t;
out->z = v->z * t;
out->w = v->w * t;
}
|