#ifndef _TPFANG_H
#define _TPFANG_H

#include "f1616.h"

typedef signed int tpfAng;

/* Contains code for manipulating angles in the range 180
   Angles are measured the regular mathematical way - i.e. zero points in the
   positive x direction, 90 degrees is positve y, etc. */

#ifdef __cplusplus
extern "C" {
#endif

/* Convert an integer degrees angle into a tpfAng
   Input must be in the range 180 */
extern tpfAng TpfAng_FromDeg(int d);

/* Convert a double radian angle into a tpfAng
   Input must be in the range PI */
extern tpfAng TpfAng_FromRad(double r);

/* Add together two tpfAng's
   Can be viewed as rotating one tpfAng by another
   Will wrap the angle if it goes above/below 180 degrees */
extern tpfAng TpfAng_Add(tpfAng a, tpfAng b);

/* Subtract two tpfAng's
   Can be viewed as rotating a by -b
   Will wrap the angle if it goes above/below 180 degrees */
extern tpfAng TpfAng_Sub(tpfAng a, tpfAng b);

/* Negate a tpfAng
   Can be viewed as reflecting the angle around 0 */
extern tpfAng TpfAng_Neg(tpfAng a);

/* Multiply a tpfAng by an integer
   May not work properly if the magnitude exceeds 180 degrees */
extern tpfAng TpfAng_Mul(tpfAng a, int b);

/* Divide a tpfAng by an integer */
extern tpfAng TpfAng_Div(tpfAng a, int b);

/* Convert a tpfAng to degrees, in the range 180 */
extern double TpfAng_ToDeg(tpfAng a);

/* Convert a tpfAng to radiangs, in the range PI */
extern double TpfAng_ToRad(tpfAng a);

/* Return the cosine of an angle as an f1616 */
extern f1616 TpfAng_cos(tpfAng a);

/* Return the sine of an angle as an f1616 */
extern f1616 TpfAng_sin(tpfAng a);

#ifdef __cplusplus
}
#endif

#endif
