(2)
Here is the algorithm written in C:
extern double omega0;
extern double phi;
static double omega = 0;
double GetNextValue()
{
omega += omega0;
return sin(omega + phi);
}