Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • I wrote a class that generated a continuous sine wave using the spring equation (F = -kx, where x is the desired resting length of the spring), basically meaning that each sample of the sine wave (assuming a constant sampling rate and frequency) would only require two multiplications and two additions. The tradeoff for this solution is that it is continuous, you cannot call sin(1), then sin(5), then sin(3), you just sample from a sine wave of a set frequency. There are two other tradeoffs, memory for storage of the spring state, and the integration of floating point errors. Commented Oct 11, 2021 at 10:34
  • The integration of floating point errors does not have a large effect on the shape of the wave, it just means it tends to go in and out of sync with the sin function after multiple samplings. You can recalibrate the function by calling standard sine and cosine function once per recalibration. I don't not why I'm talking about this. I just wanted to talk about it. Because I'm very egotistical. Commented Oct 11, 2021 at 10:37
  • I wanted to test if this solution actually is faster than repeatedly calling something like sin(x) repeatedly to fill a buffer or something, but I appear to have misplaced the cable I need to actually program my Arduino. Commented Oct 11, 2021 at 10:41