aboutsummaryrefslogtreecommitdiff
path: root/m.c
diff options
context:
space:
mode:
Diffstat (limited to 'm.c')
-rw-r--r--m.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/m.c b/m.c
new file mode 100644
index 0000000..86fb968
--- /dev/null
+++ b/m.c
@@ -0,0 +1,21 @@
+#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)_1[0], 2) + pow((double)_1[1],2) + pow((double)_1[2],2) )
+ - sqrt( pow((double)_2[0], 2) + pow((double)_2[1],2) + pow((double)_2[2],2) ) );
+}