summaryrefslogtreecommitdiff
path: root/src/math/vec4.c
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-12-04 00:07:32 +0800
committerchai <chaifix@163.com>2019-12-04 00:07:32 +0800
commit2e82e2ddd0852b8063a3d6645366f53ee844e273 (patch)
tree41ec10760f2d2c9f1f782a918f48e1287da2a4b4 /src/math/vec4.c
+init
Diffstat (limited to 'src/math/vec4.c')
-rw-r--r--src/math/vec4.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/math/vec4.c b/src/math/vec4.c
new file mode 100644
index 0000000..4216a08
--- /dev/null
+++ b/src/math/vec4.c
@@ -0,0 +1,24 @@
+#include <math.h>
+
+#include "math.h"
+#include "../util/assert.h"
+#include "../core/mem.h"
+
+
+
+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);
+} \ No newline at end of file