#Include #Include #Include #Include

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include<stdio.

h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void c_cur(float x, float y, int len, float alpha, int n)
{
if(n>0) {
len=len/sqrt(2.0);
c_cur(x,y,len,alpha+45, n-1);
x=x+len*cos(alpha+45);
y=y+len*sin(alpha+45);
c_cur(x,y,len,alpha-45, n-1);
}
else
line(x,y, x+len*cos(alpha),y+len*sin(alpha));
}
void main() {
float x,y;
int len,n;
float alpha;
int gd =DETECT, gm;
printf("enter x,y,len,a,n 200 200 100 70 12");
scanf("%f%f%d%f%d",&x,&y,&len,&alpha,&n);
initgraph(&gd,&gm,"");
c_cur(x,y,len,alpha-65, n-1);
getch(); }

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<stdio.h>

struct point
{
int x,y;
};

void hermite(point p1,point p4,double r1,double r4)


{
float x,y,t;
for(t=0.0;t<=1.0;t+=.001)
{
x=(2*t*t*t-3*t*t+1)*p1.x+(-2*t*t*t+3*t*t)*p4.x+(t*t*t-
2*t*t+t)*r1+(t*t*t-t*t)*r4;
y=(2*t*t*t-3*t*t+1)*p1.y+(-2*t*t*t+3*t*t)*p4.y+(t*t*t-
2*t*t+1)*r1+(t*t*t-t*t)*r4;
putpixel(x,y,YELLOW);
}
}

int main()
{
int gd=DETECT,gm;
double r1,r4;
initgraph(&gd,&gm,"..//BGI");
point p1,p2;
printf("Enter 2 hermite points:\n");
scanf("%d%d%d%d",&p1.x,&p1.y,&p2.x,&p2.y);
printf("Enter the tangents at p1,p4");
scanf("%d%d",&r1,&r4);
cleardevice();
hermite(p1,p2,r1,r4);
putpixel(x1,y1,WHITE);
putpixel(x2,y2,WHITE);
getch();
closegraph();
return 0;
}

You might also like