【文件属性】:
文件名称:人议会制贝塞尔曲线
文件大小:3KB
文件格式:CPP
更新时间:2014-12-24 13:00:33
贝赛尔曲线
void DrawBezier(point *p)
{
point *q=(point*)malloc(sizeof(point));
q->x=p->x;
q->y=p->y;
point *b=q;
point *g=q;
point *c=(point*)malloc(sizeof(point));
point *s=p->next;
int n=f.n-1;
for(int j=0;jx=s->x;
b->y=s->y;
s=s->next;
g->next=b;
g=b;
}
g->next=NULL;
g=q;
float t;
for(float i=0.0;i<1000.0;i++)
{
t=i/1000.0;
while(true)
{ g=q;
b=g->next;
while(b!=NULL)
{
calculate(c,g,b,t);
g->x=c->x;
g->y=c->y;
if(b->next==NULL)
{
free(b);
g->next=NULL;
n--;
break;
}
g=b;
b=b->next;
}
if(n==0)
break;
}
glVertex2f(g->x,g->y);
g->x=p->x;
g->y=p->y;
q=g;
s=p->next;
for(int j=0;jx=s->x;
b->y=s->y;
s=s->next;
g->next=b;
g=b;
}
n=f.n-1;
g->next=NULL;
}
}