mathglobal.h

来自「<B>DirectX9.0 3D游戏编程</B>」· C头文件 代码 · 共 43 行

H
43
字号
/*******************************************************************
 *         Advanced 3D Game Programming using DirectX 9.0
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * copyright (c) 2003 by Peter A Walsh and Adrian Perez
 * See license.txt for modification and distribution information
 ******************************************************************/

#ifndef _MATHGLOBAL_H
#define _MATHGLOBAL_H

#ifndef EPSILON
#define EPSILON 0.001f
#endif

#ifndef PI
#define PI 3.1415926f
#endif

#ifndef SIGN_BIT
#define SIGN_BIT 0x80000000
#endif

#ifndef INV_SIGN_BIT
#define INV_SIGN_BIT 0x7FFFFFFF
#endif

#include <stdlib.h>

// perform absolute value by AND'ing out the sign bit
inline float FastFabs( const float &in )
{
	int* temp = (int*)&in;
	int out = *temp & INV_SIGN_BIT;
	return *((float*)&out);
}

// generates a random number between -1 and 1
inline float FRand()
{
	return (float)(rand()-RAND_MAX/2) / (RAND_MAX/2);
}

#endif //_MATHGLOBAL_H

⌨️ 快捷键说明

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