DirectX Math库定义了以下用于近似涉及π的不同表达式的常量:
const float XM_PI = 3.141592654f;
const float XM_2PI = 6.283185307f;
const float XM_1DIVPI = 0.318309886f;
const float XM_1DIV2PI = 0.159154943f;
const float XM_PIDIV2 = 1.570796327f;
const float XM_PIDIV4 = 0.785398163f;
另外,它还定义了以下内联函数用于在弧度和度之间进行转换:
inline float XMConvertToRadians(float fDegrees){ return fDegrees * (XM_PI / 180.0f); }
inline float XMConvertToDegrees(float fRadians){ return fRadians * (180.0f / XM_PI); }
它还定义了最小/最大功能:
template<class T> inline T XMMin(T a, T b) { return (a< b) ? a : b; }
template<class T> inline T XMMax(T a, T b) { return (a> b) ? a : b; }