#ifndef ANGLES_H
#define ANGLES_H

#include <typedefs.h>
#include <point.h>


/*!
\brief Angle functions working in radians.

A point can describe a direction.

In 2D the convention is to measure the angle
 from the x-axis in an anti clockwise direction.

A way to specify a direction in 3D is a generalization
 of 2D where a vector from the origin defines the direction,
 in this case relative to the z-axis vector. Here is a routine
 to calculate the axis and angle of rotation to rotate the
 z-axis to the current normal position.

\par Example
\verbatim
  p0 = point3<double>(.2,-.4,1.3);

  double theta; 
  point3<double> axis;
  angles::rotateaboutaxis(theta,axis,p0);
  theta *= angles::radtodeg;
  glRotated(theta,axis.x,axis.y,axis.z);
*/
class angles
{
public:
  /** Convert from radians to degrees. */
  static doublec radtodeg;
  /** Convert from degrees to radians. */
  static doublec degtorad;

  /** Get the angle assuming X is a point on a unit circle. */
  static doublec circleunit( point2<double> const  & X );
  /** Given any point get its angle. */
  static doublec circlemapto( point2<double> const  & X );
  /** Given any point get its angle. */
  static doublec circlemapto( doublec x, doublec y);

  /** Given the normal, find the angle and axis to rotate
      the z-axis to the nml position. */ 
  static void rotateaboutaxis
  (
    double & theta,
    point3<double> & axis,
    point3<double> const & nml
  );

};


#endif



