/*!
 * <File comment goes here!!>
 * 
 * Copyright (c) 200x by <your name/ organization here>
 */
#ifndef _SINETABLE_H_
#define _SINETABLE_H_

#include "TSingleton.h"
#include <math.h>

#define PI 3.14159265f
#define DEGTORAD(deg) (deg * (PI / 180))

#define SINE_TABLE_SIZE 720
#define SINE_RATIO 2.0f

class SineTable : public TSingleton<SineTable>
{
public:
	float Sin(float deg) 
	{
		int idx = (int)(deg * SINE_RATIO);
		idx %= SINE_TABLE_SIZE;
		return m_sTable[idx];
	}

	SineTable() 
	{	
		for(int i = 0; i < SINE_TABLE_SIZE; i++)
			m_sTable[i] = sin(DEGTORAD((float)i / SINE_RATIO));
	}

	~SineTable() {}

	float m_sTable[SINE_TABLE_SIZE];
};

template<> SineTable* TSingleton<SineTable>::m_pInstance = NULL;

#endif
