Hermite curve

 #include<iostream.h>

#include<conio.h>

#include<graphics.h>

#include<dos.h>

void hermite(int x1,int y1,int x2,int y2,float slope1,float slope2)

{

float x,y;

float u;

for(u=0.00;u<=1.0;u+=0.001)

{

x=(2*u*u*u-3*u*u+1)*x1+(-2*u*u*u+3*u*u)*x2+(u*u*u-2*u*u+u)*slope1*x1+(u*u*uu*u)*slope2*x2;

y=(2*u*u*u-3*u*u+1)*y1+(-2*u*u*u+3*u*u)*y2+(u*u*u-2*u*u+u)*slope1*x1+(u*u*uu*u)*slope2*x2;

putpixel(20+(int)(x+0.5),240-(int)(y+0.5),GREEN);

}

}

int main()

{

int gd=DETECT,gm;

init graph(&gd,&gm,"c:\\tc\\bgi");

int i,j,k,l,m,n,x,y,z;

hermite(120,100,300,100,0.8,-1);

getch();

close graph();

return 0;

}

Post a Comment

0 Comments