Hello, I'm creating a kind of pedometer on a bracelet with an MPU6050 accelerometer, and for that I'm relying on the following code Pedometer/Pedometer.ino at master · Perseus14/Pedometer · GitHub . I managed to make the code work, but I am in doubt in the following calculation made in the algorithm:
int mag = sqrt (pow (x - angle_x, 2) + pow (y - angle_y, 2) + pow (z - angle_z, 2)); (A)
In this line of code that I put he calculates the vector of magnitude of the signal, but to make this calculation x, y and z are equivalent to the previous angles already obtained and angle_x, angle_y, angle_z balance the current ones. My question is related to this subtraction of values, because the formula for calculating the magnitude vector of the sign is as follows:
int mag = sqrt (pow (x, 2) + pow (y, 2) + pow (z, 2)); (B)
Can anyone understand why the values were subtracted in the first formula (A) before calculating the signal magnitude vector?