2011-07-02 19:15:04 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2011-07-02 19:15:04 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2011-07-02 19:15:04 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMON_COSINETABLES_H
|
|
|
|
#define COMMON_COSINETABLES_H
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
2012-04-14 10:18:55 +00:00
|
|
|
class CosineTable {
|
|
|
|
public:
|
|
|
|
/**
|
2018-08-16 13:37:10 +00:00
|
|
|
* Construct a cosine table given the number of points
|
2012-04-14 10:18:55 +00:00
|
|
|
*
|
2018-08-16 13:37:10 +00:00
|
|
|
* @param nPoints Number of distinct radian points, which must be in range [16,65536] and be divisible by 4
|
2012-04-14 10:18:55 +00:00
|
|
|
*/
|
2018-08-16 13:37:10 +00:00
|
|
|
CosineTable(int nPoints);
|
2012-04-14 10:18:55 +00:00
|
|
|
~CosineTable();
|
|
|
|
|
|
|
|
/**
|
2013-06-08 19:37:16 +00:00
|
|
|
* Get pointer to table.
|
|
|
|
*
|
2018-08-16 13:37:10 +00:00
|
|
|
* This table contains nPoints/2 entries.
|
2018-06-02 18:58:53 +00:00
|
|
|
* Prefer to use at()
|
2013-06-08 19:37:16 +00:00
|
|
|
* The layout of this table is as follows:
|
2018-08-16 13:37:10 +00:00
|
|
|
* - Entries 0 up to (including) nPoints/4:
|
2018-06-02 18:58:53 +00:00
|
|
|
* cos(0) till (including) cos(1/2*pi)
|
2018-08-16 13:37:10 +00:00
|
|
|
* - Entries (excluding) nPoints/4 up to nPoints/2:
|
2018-06-02 18:58:53 +00:00
|
|
|
* (excluding) cos(3/2*pi) till (excluding) cos(2*pi)
|
2012-04-14 10:18:55 +00:00
|
|
|
*/
|
2018-08-16 23:47:28 +00:00
|
|
|
const float *getTable() { return _tableEOS; }
|
2012-04-14 10:18:55 +00:00
|
|
|
|
|
|
|
/**
|
2018-08-16 13:37:10 +00:00
|
|
|
* Returns cos(2*pi * index / nPoints )
|
|
|
|
* Index must be in range [0, nPoints - 1]
|
2018-08-16 23:47:28 +00:00
|
|
|
* Faster than atLegacy
|
2012-04-14 10:18:55 +00:00
|
|
|
*/
|
2018-06-02 18:58:53 +00:00
|
|
|
float at(int index) const;
|
|
|
|
|
2018-08-16 23:47:28 +00:00
|
|
|
/**
|
|
|
|
* Returns cos(2*pi * index / nPoints )
|
|
|
|
* Index must be in range [0, nPoints - 1]
|
|
|
|
*/
|
|
|
|
float atLegacy(int index) const;
|
|
|
|
|
2012-04-14 10:18:55 +00:00
|
|
|
private:
|
2018-08-16 23:47:28 +00:00
|
|
|
float *_tableEOS;
|
2012-04-14 10:18:55 +00:00
|
|
|
float *_table;
|
2018-06-02 18:58:53 +00:00
|
|
|
double _radResolution; // Smallest radian increment
|
|
|
|
int _refSize; // _nPoints / 4
|
|
|
|
int _nPoints; // range of operator[]
|
2012-04-14 10:18:55 +00:00
|
|
|
};
|
2011-07-02 19:15:04 +00:00
|
|
|
|
|
|
|
} // End of namespace Common
|
|
|
|
|
|
|
|
#endif // COMMON_COSINETABLES_H
|