summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-12-21 22:24:15 +0800
committerchai <chaifix@163.com>2019-12-21 22:24:15 +0800
commitec111247c614663d8231245a17c314b9b8b4a28c (patch)
treea66058508161da488371c90316865ae850b8be15 /src/math
parentc3f45735ecfab6e567be371758f21395e92dfef6 (diff)
*misc
Diffstat (limited to 'src/math')
-rw-r--r--src/math/math.h7
-rw-r--r--src/math/vec4.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/math/math.h b/src/math/math.h
index 8793336..e63c603 100644
--- a/src/math/math.h
+++ b/src/math/math.h
@@ -151,9 +151,9 @@ extern Vec3 vec3zero; /*(0,0,0)*/
extern Vec2 vec2zero; /*(0,0,0)*/
extern Vec4 vec4zero; /*(0,0,0)*/
-#define zerovec3 {0, 0, 0}
#define zerovec2 {0, 0}
-#define zerovec4 {0, 0, 0}
+#define zerovec3 {0, 0, 0}
+#define zerovec4 {0, 0, 0, 0}
void vec3_tostring(Vec3* v, char buf[]);
void vec3_print(Vec3* v);
@@ -186,6 +186,9 @@ void vec4_lerp(Vec4* a, Vec4* b, float t, Vec4* out);
void vec4_scale(Vec4* v, float t, Vec4* out);
+void vec4_add(Vec4* v1, Vec4* v2, Vec4* out);
+
+
/************************************************************************/
/* Matrix */
/************************************************************************/
diff --git a/src/math/vec4.c b/src/math/vec4.c
index 202aabd..71ec6b6 100644
--- a/src/math/vec4.c
+++ b/src/math/vec4.c
@@ -38,3 +38,10 @@ void vec4_scale(Vec4* v, float t, Vec4* out) {
out->z = v->z * t;
out->w = v->w * t;
}
+
+void vec4_add(Vec4* v1, Vec4* v2, Vec4* out) {
+ out->x = v1->x + v2->x;
+ out->y = v1->y + v2->y;
+ out->z = v1->z + v2->z;
+ out->w = v1->w + v2->w;
+}