C Attitude Math Library
Quaternion, Euler, and DCM math utilities for attitude control.
Loading...
Searching...
No Matches
attitude_utils.c File Reference
#include "attitude/attitude_utils.h"
#include <math.h>

Go to the source code of this file.

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.
 

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}