#include
#include
float getValue(float w,float z,float t)
{
float phi,root,sine,expo,term,wd;
phi=acos(z);
root=sqrt(1-z*z);
wd=w*root;
sine=sin(wd*t+phi);
expo=exp(-1*z*w*t);
term=1-(expo*sine/root);
return term;
}
void draw(int x[],int y[],int n)
{
int startx=50, starty=400;
int drawx1,drawy1,drawx2,drawy2,i;
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
setcolor(10);
line(50,400,400,400);
line(50,400,50,50);
line(400,400,395,395);
line(400,400,395,405);
line(50,50,55,55);
line(50,50,45,55);
for(i=0;i
{
drawx1=startx+x[i];
drawy1=starty-y[i];
drawx2=startx+x[i+1];
drawy2=starty-y[i+1];
setcolor(YELLOW);
line(drawx1,drawy1,drawx2,drawy2);
}
}
void main()
{
float w,z,t,temp;
int a[101],b[101];
int i=0;
printf("Enter the Values of Omega and Zeta : ");
scanf("%f%f",&w,&z);
for(t=0.0;t<=25.0;t+=0.25)
{
temp=getValue(w,z,t);
a[i]=t*10;
b[i]=temp*50;
i++;
}
draw(a,b,101);
}
No comments:
Post a Comment