diff options
author | David Fioramonti | 2018-06-02 11:58:53 -0700 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-25 10:18:32 +0200 |
commit | 650e26b6ab3f6ca0ae685c53fd186ae87b2f84a0 (patch) | |
tree | 89045d7f2e9f3f921149869dd4b98f7e4644ecf5 /common/sinetables.h | |
parent | eee970df1fa75ede7130a8d69b04cbc573512f9b (diff) | |
download | scummvm-rg350-650e26b6ab3f6ca0ae685c53fd186ae87b2f84a0.tar.gz scummvm-rg350-650e26b6ab3f6ca0ae685c53fd186ae87b2f84a0.tar.bz2 scummvm-rg350-650e26b6ab3f6ca0ae685c53fd186ae87b2f84a0.zip |
COMMON: Add at() index function to cosine/sine table
The cos/sin table class now has an at() function for indexing
safely into its internal array.
This allows the checking and computing of the correct
indexes to be done internally.
The indexing in allows cos/sine of 0 to 2pi to be
obtained.
The values returned by getTable are the same as before.
Comments that describe the values that the table
contains has been modified to line up with what
the code is doing.
Diffstat (limited to 'common/sinetables.h')
-rw-r--r-- | common/sinetables.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/common/sinetables.h b/common/sinetables.h index 67225c0bcb..f91592cf38 100644 --- a/common/sinetables.h +++ b/common/sinetables.h @@ -39,22 +39,32 @@ public: * Get pointer to table * * This table contains 2^bitPrecision/2 entries. + * Prefer to use at() * The layout of this table is as follows: * - Entries 0 up to (excluding) 2^bitPrecision/4: * sin(0) till (excluding) sin(1/2*pi) - * - Entries 2^bitPrecision/4 up to (excluding) 2^bitPrecision/2: + * - Entries 2^bitPrecision/4 up to 2^bitPrecision/2: * sin(pi) till (excluding) sin(3/2*pi) */ const float *getTable() { return _table; } /** - * Get pointer to table + * Returns sin(2*pi * index / 2^bitPrecision ) + * Index must be in range [0,2^bitPrecision-1] + */ + float at(int index) const; + + /** + * Get bit precision */ - int getPrecision() { return _bitPrecision; } + int getBitPrecision() { return _bitPrecision; } private: float *_table; int _bitPrecision; + double _radResolution; // Smallest radian increment + int _refSize; // _nPoints / 4 + int _nPoints; // range of operator[] }; } // End of namespace Common |