aboutsummaryrefslogtreecommitdiff
path: root/linear_algebra.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-11-18 02:56:38 +0100
committerCharles <sircharlesaze@gmail.com>2019-11-18 02:56:38 +0100
commit542ae0113ac850e0d5216c7e2dc4543e66a1237f (patch)
tree3f51675d7d90be60f5e9e5045746325c58370566 /linear_algebra.c
parent975ec3edd112c1a7908c0d97dc49592a22076b71 (diff)
downloadcub3d-542ae0113ac850e0d5216c7e2dc4543e66a1237f.tar.gz
cub3d-542ae0113ac850e0d5216c7e2dc4543e66a1237f.tar.bz2
cub3d-542ae0113ac850e0d5216c7e2dc4543e66a1237f.zip
Added rotation, mlx_clear_window feelsgoodman
Diffstat (limited to 'linear_algebra.c')
-rw-r--r--linear_algebra.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/linear_algebra.c b/linear_algebra.c
new file mode 100644
index 0000000..881f8ff
--- /dev/null
+++ b/linear_algebra.c
@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* linear_algebra.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/11/18 01:28:01 by cacharle #+# #+# */
+/* Updated: 2019/11/18 01:32:41 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "cub3d.h"
+
+t_vector vector_add(t_vector a, t_vector b)
+{
+ a.x += b.x;
+ a.y += b.y;
+ return a;
+}
+
+t_vector vector_scale(t_vector v, double scalar)
+{
+ v.x *= scalar;
+ v.y *= scalar;
+ return v;
+}
+
+/*
+** rotate counter clockwise
+*/
+
+t_vector vector_rotate(t_vector v, double angle)
+{
+ t_vector rotated;
+
+ rotated.x = cos(angle) * v.x - sin(angle) * v.y;
+ rotated.y = sin(angle) * v.x + cos(angle) * v.y;
+ return (rotated);
+}