- Main Page
- Classes
- Files

- File List
- File Members

# C:/Users/Public/AGS Final Folder/BFLETCHER D4010283/Source/Game/Source/SineTable.h

Go to the documentation of this file.

    00001
    00006 #ifndef _SINETABLE_H_
    00007 #define _SINETABLE_H_
    00008
    00009 #include "TSingleton.h"
    00010 #include <math.h>
    00011
    00012 #define PI 3.14159265f
    00013 #define DEGTORAD(deg) (deg * (PI / 180))
    00014
    00015 #define SINE_TABLE_SIZE 720
    00016 #define SINE_RATIO 2.0f
    00017
    00018 class SineTable : public TSingleton<SineTable>
    00019 {
    00020 public:
    00021         float Sin(float deg)
    00022         {
    00023                 int idx = (int)(deg * SINE_RATIO);
    00024                 idx %= SINE_TABLE_SIZE;
    00025                 return m_sTable[idx];
    00026         }
    00027
    00028         SineTable()
    00029         {
    00030                 for(int i = 0; i < SINE_TABLE_SIZE; i++)
    00031                         m_sTable[i] = sin(DEGTORAD((float)i / SINE_RATIO));
    00032         }
    00033
    00034         ~SineTable() {}
    00035
    00036         float m_sTable[SINE_TABLE_SIZE];
    00037 };
    00038
    00039 template<> SineTable* TSingleton<SineTable>::m_pInstance = NULL;
    00040
    00041 #endif