cancel
Showing results for 
Search instead for 
Did you mean: 

Demo Code calculation of Rollang is always positive - Discovery board

max1
Associate
Posted on April 18, 2014 at 19:15

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;

         }

         else

         {

           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?
0 REPLIES 0