aboutsummaryrefslogtreecommitdiff
path: root/src/m.c
blob: b1401f1978e485999d1c52d412bca74f526149a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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) ) );
}