PebbleOS
Loading...
Searching...
No Matches
Macros | Functions
trig.h File Reference
#include <stdint.h>

Macros

#define TRIG_MAX_RATIO   0xffff
 The largest value that can result from a call to sin_lookup or cos_lookup.
 
#define TRIG_MAX_ANGLE   0x10000
 Angle value that corresponds to 360 degrees or 2 PI radians.
 
#define TRIG_PI   0x8000
 Angle value that corresponds to 180 degrees or PI radians.
 
#define TRIG_FP   16
 Number of fractional bits of the fixed-point ratio used by atan2_lookup().
 
#define TRIGANGLE_TO_DEG(trig_angle)   (((trig_angle) * 360) / TRIG_MAX_ANGLE)
 Converts from a fixed point value representation to the equivalent value in degrees.
 
#define DEG_TO_TRIGANGLE(angle)   (((angle) * TRIG_MAX_ANGLE) / 360)
 Converts from an angle in degrees to the equivalent fixed point value representation.
 

Functions

int32_t sin_lookup (int32_t angle)
 Look-up the sine of the given angle from a pre-computed table.
 
int32_t cos_lookup (int32_t angle)
 Look-up the cosine of the given angle from a pre-computed table.
 
int32_t atan2_lookup (int16_t y, int16_t x)
 Look-up the arctangent of a given x, y pair.
 
uint32_t normalize_angle (int32_t angle)
 Normalize an angle to the range [0, TRIG_MAX_ANGLE].