顯示具有 STL 標籤的文章。 顯示所有文章
顯示具有 STL 標籤的文章。 顯示所有文章

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>();

0413 vector 常用函數


  • vec.push_back() - 新增元素至 vector 的尾端,必要時會進行記憶體配置。
  • vec.pop_back() - 刪除 vector 最尾端的元素。
  • vec.clear() - 清空所有元素
  • vec.size() - 取得 vector 目前持有的元素個數。
  • 把vector當陣列用以及副函式傳遞
    //main宣告 參考前篇vector用法
    vector<vector<int> > Variance_SD(m, vector<int>(n));//副函式宣告
    void SD(vector<vector<int> >&);
    
    //副函式用&接
    void SD(vector<vector<int> >& variance){
        //可以直接當array用了
        cout << variance[1][1];
    }
    
    


cocos2dx-lua 建立滑鼠監聽

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