利用 =A2*50+(1-A2)*10 算出 angle 10-50全部內插
Hw 02:
利用Code::Blocks做出內插法
#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("3D");
glutDisplayFunc(display);
glutTimerFunc(100,timer,0);
glutMainLoop();
}
沒有留言:
張貼留言