2016年4月14日 星期四

0413 c++ 使用PI

方法一 
1.On some (especially older) platforms (see the comments below) you might need to#define _USE_MATH_DEFINESand then include the necessary header file:
#include <math.h>and the value of pi can be accessed via:
M_PIIn my math.h (2014) it is defined as:
# define M_PI 3.14159265358979323846 /* pi */but check your math.h for more. An extract from the "old" math.h (in 2009):
/* Define _USE_MATH_DEFINES before including math.h to expose these macro * definitions for common math constants. These are placed under an #ifdef * since these commonly-defined names are not part of the C/C++ standards. */However:
on newer platforms (at least on my 64 bit Ubuntu 14.04) I do not need to define the _USE_MATH_DEFINESOn (recent) Linux platforms there are long double values too provided as a GNU Extension:
# define M_PIl 3.141592653589793238462643383279502884L /* pi */
方法二
const double PI =3.141592653589793238463;const float PI_F=3.14159265358979f;
方法三
      const double pi = boost::math::constants::pi<double>();

沒有留言:

張貼留言

cocos2dx-lua 建立滑鼠監聽

重要關鍵字  EVENT_MOUSE_SCROLL addEventListenerWithSceneGraphPriority      if IsPc() then --建立滑鼠監聽         local listener = cc.EventListenerMouse...