/*
 * Implementation of class PeriodicPosition
 *
 * $Date$
 * $Revision$
 *
 */

#include "Wave/PeriodicPosition.hh"

#if !(defined __WATCOMC__ && __WATCOMC__ < 1230)
using namespace std;
#endif

int
PeriodicPosition::pos (int position, int start, int length, int &sign)
{
  sign = 1;
  
  if (length <= 1)
    {
      return start;
    }
  if (position < 0)
    {
      return start + (length - (-position % length)) % length;
    }
  if (position >= length)
    {
      return start + position % length;
    }
  return start+position;
}
