2024年5月23日 星期四

week14

 

## week14

把環境設好: download opencv
小心:add PATH
小心:目錄不要改
小心:重開codeblocks

codeblocks: setting-compiler
Search directories的Compiler: C:\OpenCV2.1\include
Search directories的Linker: C:\OpenCV2.1\lib
Linker setting: cv210 cxcore210 highgui210

再把 Github 的程式下載(兩種下載法 Git指令 or Download ZIP)

再把week13-2改成week14-1

用右鍵Notepad++開 .cbp 檔,改Titlle


# week14-1_alpha_interpolation_angle_timer

1.用excel更清楚瞭解內插法

計時器
```cpp
void timer(int t) {
    glutTimerFunc(1000,timer,t+1);
    printf("起床:%d\n", t);
}

```
    glutTimerFunc(0,timer,0);
```
進階---加入新的程式碼
```cpp
float oldAngle[20] = {},newAngle[20] = {};
void timer(int t) {
    glutTimerFunc(50,timer,t+1);
    if(t%20==0) {
        if(fin==NULL) fin = fopen("angle.txt","r");
        for(int i=0;i<20;i++) {
            oldAngle[i] = newAngle[i];
            fscanf(fin,"%f",&newAngle[i]);
        }
    }
    float alpha = (t%20) / 20.0;
    for(int i=0;i<20;i++) {
        angle[i] = newAngle[i]*alpha+oldAngle[i]*(1-alpha);
    }
    glutPostRedisplay();
}
void keyboard(unsigned char key,int x,int y){
    if(key=='p') {///play播放
        glutTimerFunc(0,timer,0);
    }
```

# week14-2_angleX_angleY_10

1.把week14-1複製過來用
程式碼修改如下:
2.把float angle{20}={};改成float angleX[10]={},angleY[10]={};
3.把原本的for(int i=0;i<20;i++) 變成 for(int i=0;i<10;i++)

1.if(key=='0') angleID = 0;做到9






沒有留言:

張貼留言