我要加入 登录
声振论坛 返回首页

风花雪月的个人空间 http://home.vibunion.com/?18 [收藏] [复制] [分享] [RSS]

日志

二次B样条法绘制曲线函数

已有 767 次阅读2007-3-4 04:26 |个人分类:C/C++

void byangtiao(int *x,int *y,int n,unsigned int k)
{
unsigned int i,j;
float t,t1,t2,a,b,c,tx,ty;
*x=*(x+1);*y=*(y+1);
*(x+n+1)=*(x+n);*(y+n+1)=*(y+n);
t=1.0/k;
setcolor(13);
moveto((*x+(*(x+1)))/2.0,(*y+(*(y+1)))/2.0);
for(i=0;i<n;i++)
  {
  for(j=1;j<k;j++)
    {
    t1=j*t;
    t2=t1*t1;
    a=(t2-2*t1+1)/2.0;
    b=t1-t2+1/2.0;
    c=t2/2.0;
    tx=a*(*(x+i))+b*(*(x+i+1))+c*(*(x+i+2));
    ty=a*(*(y+i))+b*(*(y+i+1))+c*(*(y+i+2));
    lineto(tx,ty);
    }
  }
}

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 我要加入

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-18 13:39 , Processed in 0.067134 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部