From 45267e004326cd2a63afb4f7d4b6a97dbc4e5158 Mon Sep 17 00:00:00 2001
From: Orestis <orestis.malaspinas@hesge.ch>
Date: Wed, 26 Aug 2020 21:49:39 +0200
Subject: [PATCH] added friction

---
 practical_work/vec2/util.c | 9 +++++++++
 practical_work/vec2/util.h | 6 ++++++
 2 files changed, 15 insertions(+)
 create mode 100644 practical_work/vec2/util.c
 create mode 100644 practical_work/vec2/util.h

diff --git a/practical_work/vec2/util.c b/practical_work/vec2/util.c
new file mode 100644
index 0000000..a9884e2
--- /dev/null
+++ b/practical_work/vec2/util.c
@@ -0,0 +1,9 @@
+#include <stdlib.h>
+#include "util.h"
+
+double rand_to_range(double x0, double x1) {
+    double delta = x1 - x0;
+    double rescaled = (double)rand() / RAND_MAX * delta + x0;
+
+    return rescaled;
+}
diff --git a/practical_work/vec2/util.h b/practical_work/vec2/util.h
new file mode 100644
index 0000000..3e228d8
--- /dev/null
+++ b/practical_work/vec2/util.h
@@ -0,0 +1,6 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+double rand_to_range(double x0, double x1);
+
+#endif
-- 
GitLab