⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathlookup.h

📁 手机 GAME c++ 版
💻 H
字号:
////////////////////////////////////////////////////////////////////////
//
// MathLookup.h
//
// Copyright (c) 2003 Nokia Phones Ltd  All rights reserved.
//
////////////////////////////////////////////////////////////////////////

#ifndef _MATHLOOKUP_H
#define _MATHLOOKUP_H

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

#include <e32math.h>

////////////////////////////////////////////////////////////////////////

class TTrigLookup
	{
	public:
		TTrigLookup();

		void GetTrigRatios(TInt aAngle, TInt &aCos, TInt &aSin);

	private:
		void InitCosTable();

	private:
		
		enum
		{
			quadrantSizeLog	=  8,
			quadrantSize	= ( 1 << quadrantSizeLog ),
			quadrantMask	= ( quadrantSize - 1 ),
			//
			angleSizeLog	=  quadrantSizeLog + 2,
			angleSize		= ( 1 << angleSizeLog ),
			angleMask		= ( angleSize - 1 ),
			//
			cosTableSize	= ( quadrantSize + 1 ),
			//
			trigUnityLog	= 12,
			trigUnity		= ( 1 << trigUnityLog ),
		};

		TInt16 iCosRatio[cosTableSize];
	};

////////////////////////////////////////////////////////////////////////

class TRecipLookup
	{
	public:
		TRecipLookup();

		void GetReciprocal(TUint aValue, TInt &aReciprocal, TInt &aDownshift);

	private:
		void InitRecipTable();

	private:
		
		enum
		{
			recipTableSize		= 4096,
			//
			baseRecipUnityLog	=   30,
			baseRecipUnity		= ( 1 << baseRecipUnityLog),
			maxRecip			= 0x7fff,
		};

		TInt16	iRecip[recipTableSize];
		TInt8	iShift[recipTableSize];
	};

////////////////////////////////////////////////////////////////////////

class TMathLookup
	{
	public:

		void GetTrigRatios(TInt aAngle, TInt &aCos, TInt &aSin)
			{ 
			iTrig.GetTrigRatios(aAngle,aCos,aSin); 
			}

		void GetReciprocal(TUint aValue, TInt &aReciprocal, TInt &aDownshift)
			{ 
			iRecip.GetReciprocal(aValue,aReciprocal,aDownshift); 
			}

	private:
		TTrigLookup iTrig;
		TRecipLookup iRecip;
	};

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

#endif

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -