aboutsummaryrefslogtreecommitdiff
path: root/vendor/libftm/src/mat4/ftm_mat4mul.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-12 14:14:06 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-12 14:14:06 +0200
commit7b214503608550dc2853b9e01526723f8c65baf3 (patch)
treeddbc37eb2627b43eb33774bd2bf205336cd1a9e6 /vendor/libftm/src/mat4/ftm_mat4mul.c
parentd07d87964f13d3c1e6ad8c2f6d7db21101f1ef34 (diff)
downloadscop-7b214503608550dc2853b9e01526723f8c65baf3.tar.gz
scop-7b214503608550dc2853b9e01526723f8c65baf3.tar.bz2
scop-7b214503608550dc2853b9e01526723f8c65baf3.zip
Added mat4 in libftm, can rotate, scale and translate vector
Diffstat (limited to 'vendor/libftm/src/mat4/ftm_mat4mul.c')
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4mul.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/libftm/src/mat4/ftm_mat4mul.c b/vendor/libftm/src/mat4/ftm_mat4mul.c
new file mode 100644
index 0000000..553e47c
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4mul.c
@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4mul.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:22:20 by charles #+# #+# */
+/* Updated: 2020/05/12 14:03:19 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+static float st_dot(t_ftmmat4 *a, t_ftmmat4 *b, int y, int x)
+{
+ return (ftm_mat4get(a, y, 0) * ftm_mat4get(b, 0, x) +
+ ftm_mat4get(a, y, 1) * ftm_mat4get(b, 1, x) +
+ ftm_mat4get(a, y, 2) * ftm_mat4get(b, 2, x) +
+ ftm_mat4get(a, y, 3) * ftm_mat4get(b, 3, x));
+}
+
+t_ftmmat4 *ftm_mat4mul(t_ftmmat4 *dst, t_ftmmat4 *other)
+{
+ t_ftmmat4 tmp;
+ int i;
+ int j;
+
+ i = -1;
+ while (++i < 4)
+ {
+ j = -1;
+ while (++j < 4)
+ ftm_mat4set(&tmp, i, j, st_dot(dst, other, i, j));
+ }
+ i = -1;
+ while (++i < 4 * 4)
+ dst->m[i] = tmp.m[i];
+ return (dst);
+}