83 lines
1.5 KiB
C++
83 lines
1.5 KiB
C++
#ifndef _PROTO_TRIGTABLE_HPP_
|
|
#define _PROTO_TRIGTABLE_HPP_
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
#ifndef _COMMON_GLOBALDATA_HPP_
|
|
#include <common/gdata.hpp>
|
|
#endif
|
|
|
|
class GUIWindow;
|
|
class Angles;
|
|
|
|
class TrigTable
|
|
{
|
|
public:
|
|
TrigTable(void);
|
|
virtual ~TrigTable();
|
|
void build(const Angles &angles);
|
|
int cos(int theta);
|
|
int sin(int theta);
|
|
private:
|
|
TrigTable(const TrigTable &trigTable);
|
|
TrigTable &operator=(const TrigTable &trigTable);
|
|
int angle360(void)const;
|
|
void angle360(int angle360);
|
|
|
|
GlobalData<int> mCosTable;
|
|
GlobalData<int> mSinTable;
|
|
int mAngle360;
|
|
};
|
|
|
|
inline
|
|
TrigTable::TrigTable(void)
|
|
: mAngle360(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
TrigTable::TrigTable(const TrigTable &trigTable)
|
|
: mAngle360(0)
|
|
{ // private implementation
|
|
*this=trigTable;
|
|
}
|
|
|
|
inline
|
|
TrigTable::~TrigTable()
|
|
{
|
|
}
|
|
|
|
inline
|
|
TrigTable &TrigTable::operator=(const TrigTable &/*trigTable*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
int TrigTable::angle360(void)const
|
|
{
|
|
return mAngle360;
|
|
}
|
|
|
|
inline
|
|
void TrigTable::angle360(int angle360)
|
|
{
|
|
mAngle360=angle360;
|
|
}
|
|
|
|
inline
|
|
int TrigTable::cos(int theta)
|
|
{
|
|
if(theta<0)return mCosTable.operator[](theta+angle360());
|
|
else if(theta>=angle360())return mCosTable.operator[](theta-angle360());
|
|
return mCosTable.operator[](theta);
|
|
}
|
|
|
|
inline
|
|
int TrigTable::sin(int theta)
|
|
{
|
|
if(theta<0)return mSinTable.operator[](theta+angle360());
|
|
else if(theta>=angle360())return mSinTable.operator[](theta-angle360());
|
|
return mSinTable.operator[](theta);
|
|
}
|
|
#endif |