aboutsummaryrefslogtreecommitdiff
path: root/vendor/libftm
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-09 21:31:30 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-09 21:33:14 +0200
commit0ae5be6c6697f5f5f578a27c5ad9ba845aec43c9 (patch)
tree4cda3590f185cb485bf57e2dbd3d9b8b81dba6d7 /vendor/libftm
parent6618fed5933f26d9bee8a42f049115146d4a1113 (diff)
downloadscop-0ae5be6c6697f5f5f578a27c5ad9ba845aec43c9.tar.gz
scop-0ae5be6c6697f5f5f578a27c5ad9ba845aec43c9.tar.bz2
scop-0ae5be6c6697f5f5f578a27c5ad9ba845aec43c9.zip
Added basic vector and matrix library
Diffstat (limited to 'vendor/libftm')
-rw-r--r--vendor/libftm/Makefile49
-rw-r--r--vendor/libftm/README.md3
-rw-r--r--vendor/libftm/inc/libftm_vec3.h31
-rw-r--r--vendor/libftm/inc/libftm_vec4.h30
-rw-r--r--vendor/libftm/libft.abin0 -> 12818 bytes
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3add.c21
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3cross.c26
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3dot.c20
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3scale.c21
-rw-r--r--vendor/libftm/src/vec3/ftm_vec3sub.c21
-rw-r--r--vendor/libftm/src/vec4/ftm_vec4add.c22
-rw-r--r--vendor/libftm/src/vec4/ftm_vec4dot.c21
-rw-r--r--vendor/libftm/src/vec4/ftm_vec4scale.c22
-rw-r--r--vendor/libftm/src/vec4/ftm_vec4sub.c22
14 files changed, 309 insertions, 0 deletions
diff --git a/vendor/libftm/Makefile b/vendor/libftm/Makefile
new file mode 100644
index 0000000..2348458
--- /dev/null
+++ b/vendor/libftm/Makefile
@@ -0,0 +1,49 @@
+# **************************************************************************** #
+# #
+# ::: :::::::: #
+# Makefile :+: :+: :+: #
+# +:+ +:+ +:+ #
+# 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 #
+# #
+# **************************************************************************** #
+
+LIB = ar rcs
+RM = rm -f
+
+SRC_DIR = src
+INC_DIR = inc
+OBJ_DIR = obj
+
+CC = gcc
+OFLAG ?= -O0
+CCFLAGS = $(OFLAG) -I$(INC_DIR) -Wall -Wextra -Werror
+
+NAME = libft.a
+
+SRC = $(shell find $(SRC_DIR) -type f -name '*.c')
+INC = $(shell find $(INC_DIR) -type f -name '*.h')
+OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
+
+OBJ_SUB_DIR = $(shell find $(SRC_DIR) -type d | sed 's/$(SRC_DIR)/$(OBJ_DIR)/')
+
+all: prebuild $(NAME)
+
+prebuild:
+ mkdir -p $(OBJ_DIR) $(OBJ_SUB_DIR)
+
+$(NAME): $(OBJ) $(INC)
+ $(LIB) $@ $(OBJ)
+
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
+ $(CC) $(CCFLAGS) -c -o $@ $<
+
+clean:
+ $(RM) $(OBJ)
+
+fclean: clean
+ $(RM) $(NAME)
+
+re: fclean all
diff --git a/vendor/libftm/README.md b/vendor/libftm/README.md
new file mode 100644
index 0000000..0d0fbb0
--- /dev/null
+++ b/vendor/libftm/README.md
@@ -0,0 +1,3 @@
+# libftm
+
+Matrix and vector extension of the libft
diff --git a/vendor/libftm/inc/libftm_vec3.h b/vendor/libftm/inc/libftm_vec3.h
new file mode 100644
index 0000000..fc86dcb
--- /dev/null
+++ b/vendor/libftm/inc/libftm_vec3.h
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* libftm_vec3.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:38:30 by charles #+# #+# */
+/* Updated: 2020/05/09 21:12:05 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef LIBFTM_VEC3_H
+# define LIBFTM_VEC3_H
+
+/*
+** \brief 3 component vector [x, y, z]
+*/
+
+typedef struct
+{
+ float v[3];
+} t_ftmvec3;
+
+t_ftmvec3 *ftm_vec3add(t_ftmvec3 *dst, t_ftmvec3 *other);
+t_ftmvec3 *ftm_vec3sub(t_ftmvec3 *dst, t_ftmvec3 *other);
+float ftm_vec3dot(t_ftmvec3 *a, t_ftmvec3 *b);
+void ftm_vec3cross(t_ftmvec3 *dst, t_ftmvec3 *a, t_ftmvec3 *b);
+t_ftmvec3 *ftm_vec3scale(t_ftmvec3 *dst, float scalar);
+
+#endif
diff --git a/vendor/libftm/inc/libftm_vec4.h b/vendor/libftm/inc/libftm_vec4.h
new file mode 100644
index 0000000..e89bd89
--- /dev/null
+++ b/vendor/libftm/inc/libftm_vec4.h
@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* libftm.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:48:30 by charles #+# #+# */
+/* Updated: 2020/05/09 21:11:12 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef LIBFTM_VEC4_H
+# define LIBFTM_VEC4_H
+
+/*
+** \brief 4 component vector [x, y, z, w]
+*/
+
+typedef struct
+{
+ float v[4];
+} t_ftmvec4;
+
+t_ftmvec4 *ftm_vec4add(t_ftmvec4 *dst, t_ftmvec4 *other);
+t_ftmvec4 *ftm_vec4sub(t_ftmvec4 *dst, t_ftmvec4 *other);
+float ftm_vec4dot(t_ftmvec4 *a, t_ftmvec4 *b);
+t_ftmvec4 *ftm_vec4scale(t_ftmvec4 *dst, float scalar);
+
+#endif
diff --git a/vendor/libftm/libft.a b/vendor/libftm/libft.a
new file mode 100644
index 0000000..dc5b185
--- /dev/null
+++ b/vendor/libftm/libft.a
Binary files differ
diff --git a/vendor/libftm/src/vec3/ftm_vec3add.c b/vendor/libftm/src/vec3/ftm_vec3add.c
new file mode 100644
index 0000000..9b5bd09
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3add.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3add.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:35:59 by charles #+# #+# */
+/* Updated: 2020/05/09 21:14:12 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+t_ftmvec3 *ftm_vec3add(t_ftmvec3 *dst, t_ftmvec3 *other)
+{
+ dst->v[0] += other->v[0];
+ dst->v[1] += other->v[1];
+ dst->v[2] += other->v[2];
+ return (dst);
+}
diff --git a/vendor/libftm/src/vec3/ftm_vec3cross.c b/vendor/libftm/src/vec3/ftm_vec3cross.c
new file mode 100644
index 0000000..c27534e
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3cross.c
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3cross.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 21:20:41 by charles #+# #+# */
+/* Updated: 2020/05/09 21:25:44 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+/*
+** s1 = a2 * b3 - a3 * b2
+** s2 = a3 * b1 - a1 * b3
+** s3 = a1 * b2 - a2 * b1
+*/
+
+void ftm_vec3cross(t_ftmvec3 *dst, t_ftmvec3 *a, t_ftmvec3 *b)
+{
+ dst->v[0] = a->v[1] * b->v[2] - a->v[2] * b->v[1];
+ dst->v[1] = a->v[2] * b->v[0] - a->v[0] * b->v[2];
+ dst->v[2] = a->v[0] * b->v[1] - a->v[1] * b->v[0];
+}
diff --git a/vendor/libftm/src/vec3/ftm_vec3dot.c b/vendor/libftm/src/vec3/ftm_vec3dot.c
new file mode 100644
index 0000000..5d67ce6
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3dot.c
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3dot.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 21:06:09 by charles #+# #+# */
+/* Updated: 2020/05/09 21:14:44 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+float ftm_vec3dot(t_ftmvec3 *a, t_ftmvec3 *b)
+{
+ return (a->v[0] * b->v[0] +
+ a->v[1] * b->v[1] +
+ a->v[2] * b->v[2]);
+}
diff --git a/vendor/libftm/src/vec3/ftm_vec3scale.c b/vendor/libftm/src/vec3/ftm_vec3scale.c
new file mode 100644
index 0000000..8782675
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3scale.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3scale.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 21:00:32 by charles #+# #+# */
+/* Updated: 2020/05/09 21:14:10 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+t_ftmvec3 *ftm_vec3scale(t_ftmvec3 *dst, float scalar)
+{
+ dst->v[0] *= scalar;
+ dst->v[1] *= scalar;
+ dst->v[2] *= scalar;
+ return (dst);
+}
diff --git a/vendor/libftm/src/vec3/ftm_vec3sub.c b/vendor/libftm/src/vec3/ftm_vec3sub.c
new file mode 100644
index 0000000..880acbc
--- /dev/null
+++ b/vendor/libftm/src/vec3/ftm_vec3sub.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec3sub.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:57:33 by charles #+# #+# */
+/* Updated: 2020/05/09 21:14:20 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec3.h"
+
+t_ftmvec3 *ftm_vec3sub(t_ftmvec3 *dst, t_ftmvec3 *other)
+{
+ dst->v[0] -= other->v[0];
+ dst->v[1] -= other->v[1];
+ dst->v[2] -= other->v[2];
+ return (dst);
+}
diff --git a/vendor/libftm/src/vec4/ftm_vec4add.c b/vendor/libftm/src/vec4/ftm_vec4add.c
new file mode 100644
index 0000000..bf8ef1d
--- /dev/null
+++ b/vendor/libftm/src/vec4/ftm_vec4add.c
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec4add.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:45:59 by charles #+# #+# */
+/* Updated: 2020/05/09 21:15:07 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec4.h"
+
+t_ftmvec4 *ftm_vec4add(t_ftmvec4 *dst, t_ftmvec4 *other)
+{
+ dst->v[0] += other->v[0];
+ dst->v[1] += other->v[1];
+ dst->v[2] += other->v[2];
+ dst->v[3] += other->v[3];
+ return (dst);
+}
diff --git a/vendor/libftm/src/vec4/ftm_vec4dot.c b/vendor/libftm/src/vec4/ftm_vec4dot.c
new file mode 100644
index 0000000..dc8864a
--- /dev/null
+++ b/vendor/libftm/src/vec4/ftm_vec4dot.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec4dot.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 21:06:09 by charles #+# #+# */
+/* Updated: 2020/05/09 21:15:32 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec4.h"
+
+float ftm_vec4dot(t_ftmvec4 *a, t_ftmvec4 *b)
+{
+ return (a->v[0] * b->v[0] +
+ a->v[1] * b->v[1] +
+ a->v[2] * b->v[2] +
+ a->v[3] * b->v[3]);
+}
diff --git a/vendor/libftm/src/vec4/ftm_vec4scale.c b/vendor/libftm/src/vec4/ftm_vec4scale.c
new file mode 100644
index 0000000..ddff937
--- /dev/null
+++ b/vendor/libftm/src/vec4/ftm_vec4scale.c
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec4scale.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 21:00:42 by charles #+# #+# */
+/* Updated: 2020/05/09 21:15:21 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec4.h"
+
+t_ftmvec4 *ftm_vec4scale(t_ftmvec4 *dst, float scalar)
+{
+ dst->v[0] *= scalar;
+ dst->v[1] *= scalar;
+ dst->v[2] *= scalar;
+ dst->v[3] *= scalar;
+ return (dst);
+}
diff --git a/vendor/libftm/src/vec4/ftm_vec4sub.c b/vendor/libftm/src/vec4/ftm_vec4sub.c
new file mode 100644
index 0000000..8082ddd
--- /dev/null
+++ b/vendor/libftm/src/vec4/ftm_vec4sub.c
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ftm_vec4sub.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/09 20:57:43 by charles #+# #+# */
+/* Updated: 2020/05/09 21:15:13 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libftm_vec4.h"
+
+t_ftmvec4 *ftm_vec4sub(t_ftmvec4 *dst, t_ftmvec4 *other)
+{
+ dst->v[0] -= other->v[0];
+ dst->v[1] -= other->v[1];
+ dst->v[2] -= other->v[2];
+ dst->v[3] -= other->v[3];
+ return (dst);
+}