Jump to content

DBaz

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by DBaz

  1. You're welcome. I wasn't completely happy providing it without really describing why it works. As well, my conversion to int was a little clumsy, so I did some more digging. Unfortunately the original derivation was at http://www.devmaster.net/forums/showthread.php?t=5784 but is no longer available. It is based loosely on a Taylor series I think; there is an explanation of an alternative method at http://www.coranac.com/2009/07/sines/ which makes reference to it. I did, however find a different implementation already done in fixed point at http://www.console-dev.de/2009/07/06/sine-approximation-with-fixed-point-math/ It was only the low precision version, and had some redunant conversions, so I cleaned it up and it's attached. F32SinHP.txt
  2. You can try this... it is based on http://www.mclimatiano.com/faster-sine-approximation-using-quadratic-curve/ Since you said only with Integers I had to scale the input and output, there are notes in the code. They could be rescaled to different ranges if you want. I also looked at some extensions for accuracy using different rounding, but this is the simplest version and is pretty close. The SinShortLP is a rough approximation, while the SinShortHP is a better approximation; not quite exact but close. See the link for more info. All the notes about casting are because it is sensitive to the word extensions on multiplies and it uses right shifts for division, so you have to be careful with the typing. Sorry, I did it in C# but you should be able to port it quite easily. SinIntegerApproximation.txt
×
×
  • Create New...