2016年5月30日 星期一

嗨˙_˙

作業一
用Excel作內插
以下為結果


接下來則是畫出圖表
如下


作業二
創造一個茶壺然後讓他向左邊慢慢位移並用視窗記錄下它移動的數值
以下是程式碼以及執行後的圖片
#include <stdio.h>
#include <GL/glut.h>
float pos=0, oldX=0.7, newX=0.1;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(pos, 0,0);
        glutSolidTeapot(0.2);
    glPopMatrix();
    glutSwapBuffers();
}
void timer (int t)
{
    float alpha=t/100.0;
    pos = newX*alpha+oldX*(1-alpha);
    printf("%d %f %f \n",t,alpha,pos);
    glutTimerFunc(100,timer,t+1);
    glutPostRedisplay();
}
int main (int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("123");
    glutDisplayFunc(display);
    glutTimerFunc(100,timer,0);
    glutMainLoop();
}

這則是有關期末作品的主程式



















沒有留言:

張貼留言