Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
//‚лЇ®«Ё« Ѓ аЄ®ў ЊЏ40
//Џа®Ја ¬¬ аЁбгҐв ЄаЁўлҐ Ї® «Ј®аЁв¬г ‚-бЇ« ©®ў (Є зҐб⢥® ᤥ« )
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
int N;
float T[50];
float BSPLm(int m,int i, float t)
{
if(m==0)
{
if ((t>=T[i])&&(t<=T[i+1]))
return 1;
else
return 0;
}
else
{
return ((t-T[i])/(T[i+m]-T[i])*BSPLm(m-1,i,t))+((T[i+m+1]-t)/(T[i+m+1]-T[i+1])*BSPLm(m-1,i+1,t));
}
}
struct point{float x,y;} P[20];
void main(void)
{ clrscr();
int gmode=VGAHI,gdriver=VGA;
int j;
float dx,dy;
float tt;
for(j=0;j<50;j++)
T[j]=j;
cout<<"‚ўҐ¤ЁвҐ Є®««ЁзҐбвў® ®Ї®але в®зҐЄ: ";
cin>>N;
N+=2;
randomize();
initgraph(&gdriver,&gmode,"E:\\c3.1\\bgi");
do
{
cleardevice();
for(j=1;j<N-1;j++)
{
P[j].x=random(640);
P[j].y=random(480);
}
P[0].x=2*(P[1].x)-P[2].x;
P[N-1].x=2*(P[N-2].x)-P[N-3].x;
P[0].y=2*(P[1].y)-P[2].y;
P[N-1].y=2*(P[N-2].y)-P[N-3].y;
setcolor(2);
for(j=1;j<N-2;j++)
{
line(P[j].x,P[j].y,P[j+1].x,P[j+1].y);
}
tt=3;
float sx;
float sy;
float BS;
while(tt<=T[N])
{
sx=0;
sy=0;
for(j=0;j<N;j++)
{
BS=BSPLm(3,j,tt);
sx=sx+(P[j].x)*BS;
sy=sy+(P[j].y)*BS;
}
putpixel(sx,sy,4);
tt=tt+0.0001;
}
}
while(getch()!=13);
closegraph();
}