aboutsummaryrefslogtreecommitdiff
path: root/src/m.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-05-04 00:57:44 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-05-04 00:57:44 +0200
commitf15b53eea4b7054826f79836e207751e86ba1cec (patch)
tree1373166457009a8ca25f3edf66cbdb99987f0585 /src/m.c
parent099c4db0a3a8e77deb7af7436faec802fe9401de (diff)
downloadAsciiMap-f15b53eea4b7054826f79836e207751e86ba1cec.tar.gz
Reorganised folder structure
Diffstat (limited to 'src/m.c')
-rw-r--r--src/m.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/m.c b/src/m.c
new file mode 100644
index 0000000..b1401f1
--- /dev/null
+++ b/src/m.c
@@ -0,0 +1,22 @@
+#include "m.h"
+
+uint8_t avg(int argc, uint8_t *argv)
+{
+ uint8_t ret = 0;
+ uint64_t sum = 0;
+
+ for(int i = 0; i < argc; i++)
+ sum += (uint64_t)argv[i];
+
+ ret = (char)(sum / argc);
+
+ return ret;
+}//avg
+
+
+float distance(uint8_t _1[3], uint8_t _2[3])
+{
+ return fabs( sqrt( pow((double)_2[0] - (double)_1[0], 2) +
+ pow((double)_2[1] - (double)_1[1], 2) +
+ pow((double)_2[2] - (double)_1[2], 2) ) );
+}