/***************************************************************
   rotate_vector()

      angle is in radians; the angle from the old axes to the new.
      It is assumed that if either component is bad,
      the u component will be flagged as BADFLOAT.
*/
#include "common.h"      /* needed for vector.h */
#include "vector.h"

#if PROTOTYPE_ALLOWED
void rotate_vector(double angle, float *u, float *v, int n)
#else
void rotate_vector(angle, u, v, n)
double angle;
float *u, *v;
int n;
#endif
{
   int i;
   double c, s;
   float *uu, *vv;
   double urot;       /* hold rotated u while calculating rotated v */

   c = cos(angle);
   s = sin(angle);
   uu = u;
   vv = v;
   for (i=0; i<n; i++, uu++, vv++)
   {
      if ( good_float(*uu) )
      {
         urot = (*uu * c)  + (*vv * s);
         *vv  = (*uu * -s) + (*vv * c);
         *uu = urot;
      }
   }
}                       /* rotate_vector */
