/*+++++++++
.Header		trigo.h
.LANGUAGE	C
.AUTHOR		Francois Ochsenbein [ESO-IPG]
.KEYWORDS	Trigonometric mathematical functions
.COMMENTS	This header contains declarations for mathematical functions
		and macros for spherical/hyperbolic transformations.

.VERSION 1.0	21-Oct-1985: Creation
.VERSION 1.1	05-Dec-1988: Transformed some macros to functions
.VERSION 1.2	15-Feb-1995: ANSI-compatible
----------------*/

#ifndef  TRIGO_DEF
#define  TRIGO_DEF	0

#ifndef _ARGS
#ifdef __STDC__
#define _ARGS(A)	A       /* ANSI */
#else
#define _ARGS(A)	()      /* Traditional */
#define const
#endif
#endif

#include <math.h>	/* Use system Math Library */

              					/* constants */
#ifdef M_PI
#define PI	M_PI
#else
#define PI   	3.14159265358979325e0
#endif
#define DEG  	(180.e0/PI)  			/* radians to degrees 	*/
			/* =57.295779513082320e0     			*/
#define ARCSEC  (3600.e0*DEG)  			/* radians to arcsec 	*/
#define MAS  	(1000.*ARCSEC) 			/* radians to mas 	*/

/*=========================================================================
		1. Trigonometric functions
 *=========================================================================*/

/* Standard:  	sin(x) cos(x) tan(x) sinh(x) cosh(x) tanh(x)	*/

	/* Argument in degrees: */

double cosd   _ARGS((double x));
double sind   _ARGS((double x));
double tand   _ARGS((double x));
double acosd  _ARGS((double x));
double asind  _ARGS((double x));
double atand  _ARGS((double x));
double atan2d _ARGS((double x, double y));

/*=========================================================================
		2. Spherical functions
 *=========================================================================*/

int 	tr_ou 	_ARGS((double o[2] , double u[3]));
int 	tr_uo 	_ARGS((double u[3] , double o[2]));
int	tr_Euler _ARGS((double Euler_angles[3], double R[3][3]));
		/* Surface of a `rectangle' on the sphere */
double	surf_o	_ARGS((double o1[2], double o2[2]));	/* Pos. in degrees  */
double	surf_p	_ARGS((double p1[2], double p2[2]));	/* On gnomonic proj.*/
double	surf_u3	_ARGS((double u1[3], double u2[3], 
				     double u3[3]));	/* Spher. Triangle  */
	/* Distances between two points on the sphere (degrees) */
double	s2d_u	_ARGS((double u1[3], double u2[3]));
double	s2d_o	_ARGS((double o1[2], double o2[2]));
double	s2d_p	_ARGS((double p1[2], double p2[2]));
double	dist_u	_ARGS((double u1[3], double u2[3]));
double	dist_o	_ARGS((double o1[2], double o2[2]));
double	dist_p	_ARGS((double p1[2], double p2[2]));

	/* Simple rotations with a 3x3 rotation matrix */
int    tr_RR	_ARGS((double r2[3][3] , double out[3][3], double r1[3][3]));
int    tr_oo 	_ARGS((double o_in[2] , double o_out[2], double R[3][3]));
int    tr_oo1	_ARGS((double o_in[2] , double o_out[2], double R[3][3]));
int    tr_oR 	_ARGS((double o[2] , double R[3][3] ));
int    tr_uR	_ARGS((double u[3] , double R[3][3] ));
#ifndef DEF_tr_uu
int    tr_uu	_ARGS((double u_in[3] , double u_out[3] , double R[3][3] ));
int    tr_uu1	_ARGS((double u_in[3] , double u_out[3] , double R[3][3] ));
#endif

/*=========================================================================
		3. Other standard Math Functions
 *=========================================================================*/

/* Standard: log(x) log10(x) exp(x) sqrt(x) 	*/
/* Standard: hypoth(x,y)= sqrt(x*x + y*y)	*/
/* Standard: pow(x,y) 	= x**y			*/

double sinc  _ARGS((double x));		/* sin(x)/x */
double asinc _ARGS((double x));		/* asin(x)/x */
double acosh _ARGS((double x));
double asinh _ARGS((double x));
double atanh _ARGS((double x));


/*=========================================================================
		4. Arithmetic operations
 *=========================================================================*/

/* Standard: ceil(x) floor(x) fabs(x) 	*/
/* Standard: fmod(x,y) = x%y, with same sign as x */

					/* trigo functions in degrees*/
/*=========================================================================
		5. Mantissa / Exponent Conversions
 *=========================================================================*/

/* Standard: m = frexp (x, &e)	Returns m and e such that x = m * 2**e 	
					with |m| in range [0.5, 1[	*/
/* Standard: y = ldexp (m,  e) 	Returns y = m * 2**e 			*/
/* Standard: f = modf  (x, &E) 	Returns f and E (double) with x = E + f
					f = fractional part with same
						sign as x		*/
						
#endif
