AnsweredAssumed Answered

Demo Code calculation of Rollang is always positive - Discovery board

Question asked by windels.max on Apr 18, 2014
In the Demo code for the stm32f3discovery the Rollang calculation appears to be incorrect.
The author chose to use the acos function and apply quadrant correction instead of using atan2(x,y) function which handles the sign of the two terms.
the code line
fCosRoll = sqrt(1.0-(fSinRoll * fSinRoll));
will always be a positive number.
The quadrant test will always take the the postive branch in this code,
         if (fCosRoll>0)
           RollAng = acos(fCosRoll)*180/PI;
           RollAng = acos(fCosRoll)*180/PI + 180;

The calculated value for RollAng will always be positive since fCosRoll is always positive.

Is my logic correct? Has this been brought up before? Is there any revised code from st?