summaryrefslogtreecommitdiff
path: root/src/math/vec4.c
blob: ca64820567e557b7581e34df0104593954ca6a16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <math.h>

#include "math.h"
#include "../util/assert.h"
#include "../core/mem.h"

Vec4 vec4zero = { 0, 0, 0,0 };

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);
}