summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-02-22 18:17:06 +0800
committerchai <chaifix@163.com>2020-02-22 18:17:06 +0800
commit9c89460e136ed6c6c43704d9a3a15105e0f006b0 (patch)
treecd56f1dfc10650cfbfe7007ee3432ee32227edc3 /src/math
parentd49f3d3f73709a9a7c0bce53aa13ed28a2bd27cb (diff)
*wog
Diffstat (limited to 'src/math')
-rw-r--r--src/math/mat.c2
-rw-r--r--src/math/math.h1
-rw-r--r--src/math/vec4.c9
3 files changed, 11 insertions, 1 deletions
diff --git a/src/math/mat.c b/src/math/mat.c
index 8b32ba2..592dd5e 100644
--- a/src/math/mat.c
+++ b/src/math/mat.c
@@ -706,7 +706,7 @@ bool mat4_toeuler(Mat4* in, Euler* out) {
}
}
-/*from unity src*/
+/*from unity source*/
/*https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/*/
void mat4_toquat(Mat4* in, Quat* out) {
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
diff --git a/src/math/math.h b/src/math/math.h
index 1c2a9c0..1c65c01 100644
--- a/src/math/math.h
+++ b/src/math/math.h
@@ -179,6 +179,7 @@ void vec3_lerp(Vec3* v1, Vec3* v2, float t, Vec3* out);
void vec3_slerp(Vec3* v1, Vec3* v2, float t, Vec3* out);
void vec4_dividew(Vec4* v, Vec3* out);
+void vec4_dividewnoz(Vec4* v, Vec4* out);
void vec4_tostring(Vec4* v, char buf[]);
void vec4_print(Vec4* v);
diff --git a/src/math/vec4.c b/src/math/vec4.c
index 71ec6b6..3d6df46 100644
--- a/src/math/vec4.c
+++ b/src/math/vec4.c
@@ -16,6 +16,15 @@ void vec4_dividew(Vec4* v, Vec3* out) {
out->z = v->z * w;
}
+void vec4_dividewnoz(Vec4* v, Vec4* 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;
+ out->w = v->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);
}