aboutsummaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
m---------vendor/libft0
-rw-r--r--vendor/libftm/Makefile4
-rw-r--r--vendor/libftm/inc/libftm.h20
-rw-r--r--vendor/libftm/inc/libftm_mat4.h35
-rw-r--r--vendor/libftm/inc/libftm_vec3.h23
-rw-r--r--vendor/libftm/src/ftm_radian.c18
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4get.c18
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4init_eye.c23
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4init_fill.c26
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4mul.c40
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4rotate.c70
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4scale.c25
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4set.c19
-rw-r--r--vendor/libftm/src/mat4/ftm_mat4translate.c25
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3init.c21
15 files changed, 365 insertions, 2 deletions
diff --git a/vendor/libft b/vendor/libft
-Subproject a4b9cda7d6733f2b077f8586e3b3e69351e7dfb
+Subproject b9f000a80cbba38b8f21c9737a42f07573ec7b9
diff --git a/vendor/libftm/Makefile b/vendor/libftm/Makefile
index 2348458..10b2bbd 100644
--- a/vendor/libftm/Makefile
+++ b/vendor/libftm/Makefile
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/05/09 20:44:53 by charles #+# #+# #
-# Updated: 2020/05/09 21:20:08 by charles ### ########.fr #
+# Updated: 2020/05/12 11:43:06 by charles ### ########.fr #
# #
# **************************************************************************** #
@@ -21,7 +21,7 @@ CC = gcc
OFLAG ?= -O0
CCFLAGS = $(OFLAG) -I$(INC_DIR) -Wall -Wextra -Werror
-NAME = libft.a
+NAME = libftm.a
SRC = $(shell find $(SRC_DIR) -type f -name '*.c')
INC = $(shell find $(INC_DIR) -type f -name '*.h')
diff --git a/vendor/libftm/inc/libftm.h b/vendor/libftm/inc/libftm.h
new file mode 100644
index 0000000..9755d68
--- /dev/null
+++ b/vendor/libftm/inc/libftm.h
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* libftm.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:07:32 by charles #+# #+# */
+/* Updated: 2020/05/12 13:42:27 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef LIBFTM_H
+# define LIBFTM_H
+
+# include <math.h>
+
+float ftm_radian(float degree);
+
+#endif
diff --git a/vendor/libftm/inc/libftm_mat4.h b/vendor/libftm/inc/libftm_mat4.h
new file mode 100644
index 0000000..f69d7e6
--- /dev/null
+++ b/vendor/libftm/inc/libftm_mat4.h
@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* libftm_mat4.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:04:59 by charles #+# #+# */
+/* Updated: 2020/05/12 13:53:40 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef LIBFTM_MAT4_H
+# define LIBFTM_MAT4_H
+
+# include <stddef.h>
+# include <math.h>
+# include "libftm_vec3.h"
+
+typedef struct
+{
+ float m[4 * 4];
+} t_ftmmat4;
+
+t_ftmmat4 *ftm_mat4init_eye(t_ftmmat4 *mat4, float x);
+t_ftmmat4 *ftm_mat4init_fill(t_ftmmat4 *mat4, float x);
+t_ftmmat4 *ftm_mat4translate(t_ftmmat4 *mat4, float x, float y, float z);
+t_ftmmat4 *ftm_mat4rotate(t_ftmmat4 *mat4, float radian, t_ftmvec3 *axis);
+t_ftmmat4 *ftm_mat4scale(t_ftmmat4 *mat4, float x, float y, float z);
+t_ftmmat4 *ftm_mat4mul(t_ftmmat4 *dst, t_ftmmat4 *other);
+t_ftmmat4 *ftm_mat4set(t_ftmmat4 *mat4, size_t y, size_t x, float value);
+float ftm_mat4get(t_ftmmat4 *mat4, size_t y, size_t x);
+
+
+#endif
diff --git a/vendor/libftm/inc/libftm_vec3.h b/vendor/libftm/inc/libftm_vec3.h
new file mode 100644
index 0000000..e9df2c7
--- /dev/null
+++ b/vendor/libftm/inc/libftm_vec3.h
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* libftm_vec3.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:02:29 by charles #+# #+# */
+/* Updated: 2020/05/12 11:04:08 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef LIBFTM_VEC3_H
+# define LIBFTM_VEC3_H
+
+typedef struct
+{
+ float v[3];
+} t_ftmvec3;
+
+t_ftmvec3 *ftm_vec3init(t_ftmvec3 *vec3, float x, float y, float z);
+
+#endif
diff --git a/vendor/libftm/src/ftm_radian.c b/vendor/libftm/src/ftm_radian.c
new file mode 100644
index 0000000..6e1e380
--- /dev/null
+++ b/vendor/libftm/src/ftm_radian.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_radian.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:08:29 by charles #+# #+# */
+/* Updated: 2020/05/12 11:19:17 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm.h"
+
+float ftm_radian(float degree)
+{
+ return ((degree / 180.0) * M_PI);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4get.c b/vendor/libftm/src/mat4/ftm_mat4get.c
new file mode 100644
index 0000000..3223788
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4get.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4get.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 13:54:08 by charles #+# #+# */
+/* Updated: 2020/05/12 13:54:09 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+float ftm_mat4get(t_ftmmat4 *mat4, size_t y, size_t x)
+{
+ return (mat4->m[y * 4 + x]);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4init_eye.c b/vendor/libftm/src/mat4/ftm_mat4init_eye.c
new file mode 100644
index 0000000..d32f075
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4init_eye.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4init_eye.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:10:44 by charles #+# #+# */
+/* Updated: 2020/05/12 12:17:21 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+t_ftmmat4 *ftm_mat4init_eye(t_ftmmat4 *mat4, float x)
+{
+ ftm_mat4init_fill(mat4, 0.0);
+ ftm_mat4set(mat4, 0, 0, x);
+ ftm_mat4set(mat4, 1, 1, x);
+ ftm_mat4set(mat4, 2, 2, x);
+ ftm_mat4set(mat4, 3, 3, x);
+ return (mat4);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4init_fill.c b/vendor/libftm/src/mat4/ftm_mat4init_fill.c
new file mode 100644
index 0000000..d7b0b3a
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4init_fill.c
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4init_fill.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 12:16:59 by charles #+# #+# */
+/* Updated: 2020/05/12 12:18:01 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+t_ftmmat4 *ftm_mat4init_fill(t_ftmmat4 *mat4, float x)
+{
+ size_t i;
+
+ i = 0;
+ while (i < 4 * 4)
+ {
+ mat4->m[i] = x;
+ i++;
+ }
+ return (mat4);
+}
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);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4rotate.c b/vendor/libftm/src/mat4/ftm_mat4rotate.c
new file mode 100644
index 0000000..0a39c16
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4rotate.c
@@ -0,0 +1,70 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4rotate.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:44:18 by charles #+# #+# */
+/* Updated: 2020/05/12 14:05:18 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+/*
+** Rotation axis/vector [x, y, z]
+**
+** 1st column:
+** | cos(θ) + x^2 (1 − cos(θ)) |
+** | y x (1 − cos(θ)) + z sin(θ) |
+** | z x (1 − cos(θ)) − y sin(θ) |
+** | 0 |
+**
+** 2nd column:
+** | x y (1 − cos(θ)) − z sin(θ) |
+** | cos(θ) + y^2 (1 − cos(θ)) |
+** | z y (1 − cos(θ)) + x sin(θ) |
+** | 0 |
+**
+** 3rd column:
+** | x z (1 − cos(θ)) + y sin(θ) |
+** | y z (1 − cos(θ)) − x sin(θ) |
+** | cos(θ) + z^2 (1 − cos(θ)) |
+** | 0 |
+*/
+
+t_ftmmat4 *ftm_mat4rotate(t_ftmmat4 *mat4, float theta, t_ftmvec3 *axis)
+{
+ float x;
+ float y;
+ float z;
+ float sin_t;
+ float cos_t;
+ t_ftmmat4 rot;
+
+ x = axis->v[0];
+ y = axis->v[1];
+ z = axis->v[2];
+ sin_t = sin(theta);
+ cos_t = cos(theta);
+ ftm_mat4init_fill(&rot, 0.0);
+ ftm_mat4set(&rot, 0, 0, cos_t + x * x * (1 - cos_t));
+ ftm_mat4set(&rot, 1, 0, y * x * (1 - cos_t) + z * sin_t);
+ ftm_mat4set(&rot, 2, 0, z * x * (1 - cos_t) + y * sin_t);
+ ftm_mat4set(&rot, 3, 0, 0.0);
+
+ ftm_mat4set(&rot, 0, 1, x * y * (1 - cos_t) - z * sin_t);
+ ftm_mat4set(&rot, 1, 1, cos_t + y * y * (1 - cos_t));
+ ftm_mat4set(&rot, 2, 1, z * y * (1 - cos_t) + x * sin_t);
+ ftm_mat4set(&rot, 3, 1, 0);
+
+ ftm_mat4set(&rot, 0, 2, x * z * (1 - cos_t) + y * sin_t);
+ ftm_mat4set(&rot, 1, 2, y * z * (1 - cos_t) - x * sin_t);
+ ftm_mat4set(&rot, 2, 2, cos_t + z * z * (1 - cos_t));
+ ftm_mat4set(&rot, 3, 2, 0);
+
+ ftm_mat4set(&rot, 3, 3, 1.0);
+ ftm_mat4mul(mat4, &rot);
+ return (mat4);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4scale.c b/vendor/libftm/src/mat4/ftm_mat4scale.c
new file mode 100644
index 0000000..a278c83
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4scale.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4scale.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:16:19 by charles #+# #+# */
+/* Updated: 2020/05/12 11:18:38 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+t_ftmmat4 *ftm_mat4scale(t_ftmmat4 *mat4, float x, float y, float z)
+{
+ t_ftmmat4 scale;
+
+ ftm_mat4init_eye(&scale, 1.0);
+ ftm_mat4set(&scale, 0, 0, x);
+ ftm_mat4set(&scale, 1, 1, y);
+ ftm_mat4set(&scale, 2, 2, z);
+ ftm_mat4mul(mat4, &scale);
+ return (mat4);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4set.c b/vendor/libftm/src/mat4/ftm_mat4set.c
new file mode 100644
index 0000000..55e8125
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4set.c
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4set.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:21:20 by charles #+# #+# */
+/* Updated: 2020/05/12 11:21:58 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+t_ftmmat4 *ftm_mat4set(t_ftmmat4 *mat4, size_t y, size_t x, float value)
+{
+ mat4->m[y * 4 + x] = value;
+ return (mat4);
+}
diff --git a/vendor/libftm/src/mat4/ftm_mat4translate.c b/vendor/libftm/src/mat4/ftm_mat4translate.c
new file mode 100644
index 0000000..38a44d9
--- /dev/null
+++ b/vendor/libftm/src/mat4/ftm_mat4translate.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_mat4translate.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:12:21 by charles #+# #+# */
+/* Updated: 2020/05/12 11:19:05 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_mat4.h"
+
+t_ftmmat4 *ftm_mat4translate(t_ftmmat4 *mat4, float x, float y, float z)
+{
+ t_ftmmat4 trans;
+
+ ftm_mat4init_eye(&trans, 1.0);
+ ftm_mat4set(&trans, 0, 3, x);
+ ftm_mat4set(&trans, 1, 3, y);
+ ftm_mat4set(&trans, 2, 3, z);
+ ftm_mat4mul(mat4, &trans);
+ return (mat4);
+}
diff --git a/vendor/libftm/src/vec3/ftm_vec3init.c b/vendor/libftm/src/vec3/ftm_vec3init.c
new file mode 100644
index 0000000..ff5047c
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3init.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3init.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/12 11:19:55 by charles #+# #+# */
+/* Updated: 2020/05/12 11:20:53 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+t_ftmvec3 *ftm_vec3init(t_ftmvec3 *vec3, float x, float y, float z)
+{
+ vec3->v[0] = x;
+ vec3->v[1] = y;
+ vec3->v[2] = z;
+ return (vec3);
+}