mathlookup.h

来自「手机 GAME c++ 版」· C头文件 代码 · 共 105 行

H
105
字号
////////////////////////////////////////////////////////////////////////
//
// 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 + =
减小字号Ctrl + -
显示快捷键?