C Attitude Math Library
Quaternion, Euler, and DCM math utilities for attitude control.
Loading...
Searching...
No Matches
attitude_utils.h File Reference

Go to the source code of this file.

Macros

#define ATTITUDE_PI   3.14159265358979323846264338327950288
 Macro helper converting degrees to radians.
 
#define DEG2RAD(x)   ((x) * ATTITUDE_PI / 180.0)
 
#define RAD2DEG(x)   ((x) * 180.0 / ATTITUDE_PI)
 Macro helper converting radians to degrees.
 

Functions

double deg2rad (double degrees)
 Convert degrees to radians.
 
double rad2deg (double radians)
 Convert radians to degrees.
 
double wrap_angle (double angle)
 Wrap an angle to the \((-\pi, \pi]\) interval.
 

Macro Definition Documentation

◆ ATTITUDE_PI

#define ATTITUDE_PI   3.14159265358979323846264338327950288

Macro helper converting degrees to radians.

Definition at line 11 of file attitude_utils.h.

◆ DEG2RAD

#define DEG2RAD (   x)    ((x) * ATTITUDE_PI / 180.0)

Definition at line 12 of file attitude_utils.h.

◆ RAD2DEG

#define RAD2DEG (   x)    ((x) * 180.0 / ATTITUDE_PI)

Macro helper converting radians to degrees.

Definition at line 16 of file attitude_utils.h.

Function Documentation

◆ deg2rad()

double deg2rad ( double  degrees)

Convert degrees to radians.

Parameters
degreesAngle in degrees.
Returns
Angle in radians.

Definition at line 4 of file attitude_utils.c.

4 {
5 return degrees * ATTITUDE_PI / 180.0;
6}
#define ATTITUDE_PI
Macro helper converting degrees to radians.

◆ rad2deg()

double rad2deg ( double  radians)

Convert radians to degrees.

Parameters
radiansAngle in radians.
Returns
Angle in degrees.

Definition at line 8 of file attitude_utils.c.

8 {
9 return radians * 180.0 / ATTITUDE_PI;
10}

◆ wrap_angle()

double wrap_angle ( double  angle)

Wrap an angle to the \((-\pi, \pi]\) interval.

Parameters
angleAngle in radians.
Returns
Wrapped angle.

Definition at line 12 of file attitude_utils.c.

12 {
13 // Wrap angle to [-pi, pi)
14 while (angle >= ATTITUDE_PI) angle -= 2.0*ATTITUDE_PI;
15 while (angle < -ATTITUDE_PI) angle += 2.0*ATTITUDE_PI;
16 return angle;
17}