Hello Everyone,
Can somone explain me this type of function?
double FunctionsPitchRoll(double A, double B, double C){
double DatoA, DatoB, Value;
DatoA = A;
DatoB = (BB) + (CC);
DatoB = sqrt(DatoB);
Value = atan2(DatoA, DatoB);
Value = Value * 180/3.14;
return (int)Value;
}
This is used for my Project to controll 2 Servo Motors with an MPU6050.
The function could be used to return an approximate pitch or roll angle in degrees, incorrectly truncated to an integer.
It won't work correctly if both pitch and roll angles are not zero, as there is dependence on the order in which the rotations are applied. The correct formula are given here.
ok, thanks for your help.
But why "value" multiplied with 180 degrees and divided by PI?
Why would you cast the return value to an int?
Was the author being paid by the LOC?
BobbyTarantino:
But why "value" multiplied with 180 degrees and divided by PI?
Because the author didn't know about the M_PI predefine?
But why "value" multiplied with 180 degrees and divided by PI?
The trig functions output in radians. That will convert the radians to degrees.