21 lines
355 B
Plaintext
Raw Normal View History

2015-03-03 15:20:55 +01:00
class Oscillator {
2015-03-04 09:33:55 +01:00
2015-03-03 15:20:55 +01:00
float _step, _theta;
float _min, _max, _length;
public Oscillator(float min, float max, float step) {
_min = min;
_max = max;
_length = max - min;
_step = step;
_theta = 0;
}
public float update() {
_theta += _step;
2015-03-04 14:09:33 +01:00
return (sin(_theta) * (_length / 2)) + (_length / 2) + _min;
2015-03-03 15:20:55 +01:00
}
}