Friday, September 15, 2017

opengl glutPostRedisplay(void)

1用法编辑
void glutPostRedisplay(void);

2描述编辑

glutPostRedisplay 标记当前窗口需要重新绘制。通过glutMainLoop下一次循环时,窗口显示将被回调以重新显示窗口的正常面板。多次调用glutPostRedisplay,在下一个显示回调只产生单一的重新显示回调。
为了便于理解,用下面的例子[1]来说明:
假设有绘制代码:
glutDisplayFunc(display); // opengl drawing goes here
glutTimerFunc(30, drive, -1);// physics, movement equations here
glutMainLoop();
另外有代码如下:
void drive (int data)
{
glutTimerFunc(30, drive, -1);// call drive() again in 30 milliseconds
glutPostRedisplay();
}
如果有glutpostredisplay,mianloop运行的过程会像下面这样:
drive (-1);
display();
drive (-1);
display();
drive (-1);
display();
...
如果没有glutPostRedisplay,glutMainloop运行的过程会像下面这样:
drive (-1);
drive (-1);
drive (-1);
...




Tuesday, July 4, 2017

圆柱度 直线度 和直径公差关系推演


上述例子基于mcmaster的直线圆柱界面导轨数据: 直线度0.001", 直径公差-0.001". 可见该导轨的圆柱度公差还是有可能达到0.002"。

Sunday, July 2, 2017

数据结构与算法--fibonacci的动态规划解法



对比下面这个用一个数组来存储中间变量的方法:以下代码为JAVA:
  1.    /** 
  2.      * 自底向上包含"动态规划"思想的解法 
  3.      * @param n 
  4.      * @return 第n个斐波那契数 
  5.      */  
  6.     public static int downToTopReslove(int n) {  
  7.         if(n == 0) {  
  8.             return 0;  
  9.         } else if(n == 1 || n == 2) {  
  10.             return 1;  
  11.         } else {  
  12.             int[] fibonacciArray = new int[n+1]; //fibonacciArray[i]表示第i个斐波那契数  
  13.             fibonacciArray[0] = 0;  
  14.             fibonacciArray[1] = 1;  
  15.             fibonacciArray[2] = 1;  
  16.             for(int i=3;i<=n;i++) { //注意由于fibonacciArray[0]表示第0个元素,这里是i<=n,而不是i<n  
  17.                 fibonacciArray[i] = fibonacciArray[i-1] + fibonacciArray[i-2];  
  18.             }  
  19.               
  20.             return fibonacciArray[fibonacciArray.length-1];  
  21.         }  
  22.     }  

第一个算法只用了两个中间变量来存储中间值,每次值都会有变化,而第二个方法则是每个中间值都被存储在了对应的数组元素里。

上述两种算法都体现了动态规划的思想。

Sunday, June 18, 2017

halfedge data structure

http://www.holmes3d.net/graphics/dcel/


C++ emplace_back:
https://www.kancloud.cn/wangshubo1989/vector/101113

emplace_back 可以在一个vector中添加一个新的object,这一添加可以免去调用该object的构造函数直接进行。

Monday, June 5, 2017

Cmake to find protobuf on windows

 I also struggled with this. To be more clear.
On Windows (7, similar on older windows): Start --> Control Panel --> System --> Advanced System Settings --> Environment Variables
Then either on the top panel or the bottom panel (if you want it to apply to other users do it on the bottom), create two new variables. The 1st one is
  • CMAKE_INCLUDE_PATH which points at the bottom of your include path (should contain a "google" folder)
  • CMAKE_LIBRARY_PATH which should contain "libprotobuf" "libprotobuf-lite" "liteprotoc" .lib files.
After you create the variables press OK and then re-start cmake (or clean the cache).


每个进程都会有一个返回值的. 
进程开始时是由系统的一个启动函数掉用了main函数的:   
int   nMainRetVal   =   main(); 
当从main函数退出后,启动函数便调用exit函数,并且把nMainRetVa传递给它. 
所以,任何时候都会调用exit函数的,正常情况下,main函数不会调用exit函数的,而是由return   0; 
返回值给nMainRetVal的,exit再接收这个值作为参数的.所以,正常情况下是以exit(0)退出的. 
如果,你程序发生异常,你可以在main函数中调用exit(1),强制退出程序,强制终止进程.其中1表示不正常退出

Saturday, May 6, 2017

neural network

back propagation
http://www.cnblogs.com/charlotte77/p/5629865.html

matlab Neural network
http://blog.csdn.net/gongxq0124/article/details/7681000/

Sunday, April 30, 2017

色度图 Chromacity Diagram

色度图:chromaticity diagram
http://netclass.csu.edu.cn/NCourse/hep089/Chapter4/CG_Txt_4_009.htm

色度图的马蹄形轮廓是如上所示的三刺激图在x,y,z三维空间中,可见光谱(380-700nm) 在x+y+z=1的平面上的的投影:

三刺激值可以理解为三个人为定义的原色对于某一可见光波长的拟合值,这一个值是一个百分比,代表各颜色所占的比例,用小写的x,y,z表示。有时候,这个值也可以被表示成各原色的值(相对值)。这时这三个值用X,Y,Z表示。

x,y,z与X,Y,Z的关系为: