3.11.10 Q15_ANGLE Macro

C

#define   Q15_ANGLE(value)         (int16_t)( value * (float32_t)Q15_SCALE_FACTOR / (float32_t)ONE_PI)

Summary

Convert the given value into an angle represented in the Q15 fixed-point format.

Description

The macro converts a given value into an angle represented in the Q15 fixed-point format. It achieves this by scaling the input value using a predefined scaling factor, Q15_SCALE_FACTOR( 2 15 ), and then normalizing it by dividing by π.

Example

float32_t angle_value = 3.14f;    
int16_t result = Q15_ANGLE(angle_value);  // Converts the value into a Q15 angle 
    

Remarks

None