code: public static int getFineDirection (double theta)
      {
          theta = ((theta + Math.PI) * 8) / Math.PI;
          return ANGLE_MAP[(int)Math.round(theta) % FINE_DIRECTION_COUNT];
      }
docs: Returns which of the sixteen compass directions is associated with the specified angle
  theta. <em>Note:</em> that the angle supplied is assumed to increase clockwise around the
  origin (which screen angles do) rather than counter-clockwise around the origin (which
  cartesian angles do) and <code>NORTH</code> is considered to point toward the top of the
  screen.