I am trying to understand this small piece of code from Joop Brokking and have ONE question.
//Accelerometer angle calculations
1 acc_total_vector = sqrt((acc_x*acc_x)+(acc_y*acc_y)+(acc_z*acc_z)); //Calculate the total accelerometer vector.
2
3if(abs(acc_y) < acc_total_vector){ //Prevent the asin function to produce a NaN
4 angle_pitch_acc = asin((float)acc_y/acc_total_vector)* 57.296; //Calculate the pitch angle.
5}
6 if(abs(acc_x) < acc_total_vector){ //Prevent the asin function to produce a NaN
7 angle_roll_acc = asin((float)acc_x/acc_total_vector)* -57.296; //Calculate the roll angle.
8 }
WHY THE NEGATIVE SIGN IN LINE 7? Can anyone clarify this? Thanks.
//Accelerometer angle calculations
1 acc_total_vector = sqrt((acc_x*acc_x)+(acc_y*acc_y)+(acc_z*acc_z)); //Calculate the total accelerometer vector.
2
3if(abs(acc_y) < acc_total_vector){ //Prevent the asin function to produce a NaN
4 angle_pitch_acc = asin((float)acc_y/acc_total_vector)* 57.296; //Calculate the pitch angle.
5}
6 if(abs(acc_x) < acc_total_vector){ //Prevent the asin function to produce a NaN
7 angle_roll_acc = asin((float)acc_x/acc_total_vector)* -57.296; //Calculate the roll angle.
8 }
WHY THE NEGATIVE SIGN IN LINE 7? Can anyone clarify this? Thanks.