===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<copyright.h>
void ch(int &ch)
{
clrscr();
rthird(6);
int x,y,i,j,I;
char c;
float Y,X;
textcolor(1);
for(i=12,I=12;I<=17;I++,i--)
{
for(x=10;x<=70;x++)
{
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i);
cprintf("þ");
}
delay(200);
for(x=10;x<=70;x++)
{
gotoxy(x,I);
cprintf(" ");
gotoxy(x,i);
cprintf(" ");
}
}
for(x=10;x<=70;x++)
{
gotoxy(x,17);
cprintf("þ");
gotoxy(x,6);
cprintf("þ");
}
i=0;
textcolor(RED);
textbackground(GREEN);
gotoxy(15,10);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(15,11);
cprintf("³GROUND PROJECTION³");
gotoxy(15,12);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
textcolor(RED);
textbackground(GREEN);
gotoxy(45,10);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(45,11);
cprintf("³HEIGHT PROJECTION³");
gotoxy(45,12);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
do
{
if(i%2==0)
{
textcolor(14+BLINK);
gotoxy(16,11);
cprintf("GROUND PROJECTION");
}
else
{
textcolor(14+BLINK);
gotoxy(46,11);
cprintf("HEIGHT PROJECTION");
}
c=getch();
if(i%2==0)
{
textcolor(RED);
gotoxy(16,11);
cprintf("GROUND PROJECTION");
}
else
{
textcolor(RED);
gotoxy(46,11);
cprintf("HEIGHT PROJECTION");
}
i++;
}while(c!=13);
if(i%2==0)
ch=2;
else
ch=1;
textbackground(6);
for(i=6,I=17,Y=0,X=10;i>=1;I++,i--,X--,++Y)
{
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i);
cprintf("þ");
}
delay(200);
for(x=X;x<=70+Y;x++)
{
gotoxy(x,I);
cprintf(" ");
gotoxy(x,i);
cprintf(" ");
}
}
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i+1);
cprintf("þ");
}
for(;I<=25;I++)
{
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
}
delay(200);
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf(" ");
}
}
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I-1);
cprintf("þ");
}
textbackground(6);
switch(ch)
{
case 1:
gotoxy(45,10);
cprintf(" ");
gotoxy(45,11);
cprintf(" ");
gotoxy(45,12);
cprintf(" ");
textcolor(RED);
textbackground(GREEN);
for(X=15,Y=10;Y>=2;Y--,X+=1.5)
{
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³GROUND PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
delay(100);
textbackground(6);
gotoxy(X,Y);
cprintf(" ");
gotoxy(X,Y+1);
cprintf(" ");
gotoxy(X,Y+2);
cprintf(" ");
}
textbackground(GREEN);
gotoxy(X+2,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X+2,Y+1);
cprintf("³GROUND PROJECTION³");
gotoxy(X+2,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
break;
case 2:
gotoxy(15,10);
cprintf(" ");
gotoxy(15,11);
cprintf(" ");
gotoxy(15,12);
cprintf(" ");
textcolor(RED);
textbackground(GREEN);
for(X=45,Y=10;Y>=2;Y--,X-=1.5)
{
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³HEIGHT PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
delay(100);
textbackground(6);
gotoxy(X,Y);
cprintf(" ");
gotoxy(X,Y+1);
cprintf(" ");
gotoxy(X,Y+2);
cprintf(" ");
}
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³HEIGHT PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
}
}
void graph(float xS,float yS,float tS)
{
int i;
textcolor(YELLOW);
rthird(6);
for(i=2;i<=79;i++)
{
gotoxy(i,25);
if(i==2)
cprintf("Ô");
else if(i==79)
cprintf(">");
else
cprintf("Ñ");
}
for(i=1;i<=24;i++)
{
gotoxy(2,i);
if(i==1)
cprintf(" ");
else
cprintf("´");
}
textcolor(BLUE);
textbackground(5);
gotoxy(50,1);
cprintf("ÉÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(50,2);
cprintf("º SCALE º º");
gotoxy(50,3);
cprintf("ÌÍÍÍÍÍÍͼ º");
gotoxy(50,4);
cprintf("º º");
gotoxy(50,5);
cprintf("º º");
gotoxy(50,6);
cprintf("º º");
gotoxy(50,7);
cprintf("º º");
gotoxy(50,8);
cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
textcolor(YELLOW);
gotoxy(60,2);
cprintf("On X axis:-");
gotoxy(60,3);
cprintf("1 Division= %.1f m",xS);
gotoxy(54,4);
cprintf("On Y axis:-");
gotoxy(54,5);
cprintf("1 Division= %.1f m",yS);
gotoxy(54,6);
cprintf("For Time:-");
gotoxy(54,7);
cprintf("%.1f sec= 1 sec",tS);
}
void height(float u,float h,float xS,float yS,float tS)
{
float y,x,v,T,t;
textbackground(6);
x=y=1;
textcolor(CYAN);
for(y=h;(y>=0 && y<=23*yS) && (x>=0 && x<=xS*76);y-=yS)
{
t=sqrt((h-y)/5);
if(y==h)
T=t;
else
T=t-T;
delay(T*tS*1000);
x=sqrt((h-y)*(u*u)/5);
gotoxy(x/xS+2,25-y/yS);
cprintf("þ");
T=t;
}
}
void ground(float theta,float u,float r,float xS,float yS,float tS)
{
float A,B,T,t,x,y,vertex,R,H,D,Y;
A=5/(u*u*pow(cos(theta*M_PI/180),2));
B=tan(theta*M_PI/180);
textbackground(6);
textcolor(CYAN);
R=u*u*sin(2*theta*M_PI/180)/10;
H=u*u*pow(sin(theta*M_PI/180),2)/20;
/* for(x=0;x<=148;x+=2)
{
y=x*B-A*x*x;
T=x/(u*cos(theta*M_PI/180));
if(y>=-1 && y<=50)
{
gotoxy(x/2+2,25-y/2);
cprintf("þ");
if(x==0)
delay(T*2000);
else
delay((T-t)*2000);
cout<<T;
}
t=T;
} */
x=y=1;
for(Y=0,y=0;(y>=0 && y<=23*yS) && (x+r>=0 && x+r<=76*xS);Y+=yS)
{
if(Y<H)
{
D=sqrt(B*B-4*A*y);
x=(B-D)/(2*A);
T=(u*sin(theta*M_PI/180)-sqrt(u*u*pow(sin(theta*M_PI/180),2)-20*y))/10;
if(x>=0 && x<=xS*R)
{
if(y==0)
delay(0);
else
delay((T-t)*tS*1000);
gotoxy((x+r)/xS+2,25-y/yS);
cprintf("þ");
}
t=T;
y+=yS;
}
else
{
if(y<=0)
break;
y-=yS;
D=sqrt(B*B-4*A*y);
x=(B+D)/(2*A);
T=(u*sin(theta*M_PI/180)+sqrt(u*u*pow(sin(theta*M_PI/180),2)-20*y))/10;
if(x>=0 && x<=xS*R)
{
delay((T-t)*tS*1000);
gotoxy((x+r)/xS+2,25-y/yS);
cprintf("þ");
}
t=T;
}
}
}
void main()
{
clrscr();
int CH;
ch(CH);
switch(CH)
{
case 1:
float h,m,theta,e,dv,KE_,T,iv,KE,PE,TE,v,R,b,M,LoKEx,LoKEy,v1,v2,KEx,KEy,vx,vy,sint,cost,u,r=0,xS,yS,tS;
char c;
textcolor(RED);
textbackground(CYAN);
gotoxy(10,5);
cprintf("Enter Initial Velocity: m/s");
gotoxy(34,5);
cscanf("%f",&u);
gotoxy(10,7);
cprintf("Enter Angle: ø");
gotoxy(23,7);
cscanf("%f",&theta);
gotoxy(10,9);
cprintf("Enter Mass: kg");
gotoxy(22,9);
cscanf("%f",&m);
gotoxy(10,11);
cprintf("Enter mass of ground: kg");
gotoxy(32,11);
cscanf("%f",&M);
xS=3;
yS=3;
tS=1;
clrscr();
graph(xS,yS,tS);
vx=u*cos(theta*M_PI/180);
KEx=0.5*m*vx*vx;
vy=u*sin(theta*M_PI/180);
KEy=0.5*m*vy*vy;
TE=KEx+KEy;
T=u*sin(theta*M_PI/180)/5;
R=u*u*sin(2*theta*M_PI/180)/10;
ground(theta,u,r,xS,yS,tS);
// KE=TE;
// v=sqrt(2*KE/m);
// sint=vy/v;
// cost=vx/v;
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
// cout<<" LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<"PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" v="<<v<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
while(TE>1)
{
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
KEx=KEx-LoKEx;
KEy=KEy-LoKEy;
vx=sqrt(2*KEx/m);
vy=sqrt(2*KEy/m);
theta=vy/vx;
theta=atan(theta)*180/M_PI;
u=sqrt(vx*vx+vy*vy);
r+=R;
ground(theta,u,r,xS,yS,tS);
cost=vx/u;
sint=vy/u;
h=u*u*sint*sint/20;
R=u*u*2*sint*cost/10;
// PE=m*10*h;
TE=KEx+KEy;
T=u*sint/5;
// cout<<"\n\n\n LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<" PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
if(kbhit()!=0)
{
c=getch();
if(c==' ')
break;
}
}
getch();
break;
case 2:
r=0;
textcolor(RED);
textbackground(CYAN);
gotoxy(10,5);
cprintf("Enter Initial Velocity: m/s");
gotoxy(34,5);
cscanf("%f",&vx);
gotoxy(10,7);
cprintf("Enter Height: m");
gotoxy(24,7);
cscanf("%f",&h);
gotoxy(10,9);
cprintf("Enter Mass: kg");
gotoxy(22,9);
cscanf("%f",&m);
gotoxy(10,11);
cprintf("Enter mass of ground: kg");
gotoxy(32,11);
cscanf("%f",&M);
xS=3;
yS=3;
tS=1;
/* gotoxy(10,15);
cprintf("Enter Scale for X axis: m");
gotoxy(34,15);
cscanf("%f",&xS);
gotoxy(10,17);
cprintf("Enter Scale for Y axis: m");
gotoxy(34,17);
cscanf("%f",&yS);
gotoxy(10,19);
cprintf("Enter Scale For Time: sec");
gotoxy(32,19);
cscanf("%f",&tS);*/
clrscr();
graph(xS,yS,tS);
height(vx,h,xS,yS,tS);
PE=m*10*h;
KEx=0.5*m*vx*vx;
KEy=0;
TE=PE+KEx+KEy;
T=sqrt(h/5);
R=vx*T;
vy=10*T;
KE=TE;
KEy=KE-KEx;
theta=vy/vx;
theta=atan(theta)*180/M_PI;
v=sqrt(2*KE/m);
sint=vy/v;
cost=vx/v;
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
// cout<<" LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<"PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" v="<<v<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
while(TE>1)
{
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
KEx=KEx-LoKEx;
KEy=KEy-LoKEy;
vx=sqrt(2*KEx/m);
vy=sqrt(2*KEy/m);
theta=vy/vx;
u=sqrt(vx*vx+vy*vy);
r+=R;
theta=atan(theta)*180/M_PI;
ground(theta,u,r,xS,yS,tS);
cost=vx/u;
sint=vy/u;
h=u*u*sint*sint/20;
R=u*u*2*sint*cost/10;
PE=m*10*h;
TE=KEx+KEy;
T=u*sint/5;
// cout<<"\n\n\n LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<" PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
if(kbhit()!=0)
{
c=getch();
if(c==' ')
break;
}
}
getch();
break;
}
}
CODING
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<copyright.h>
void ch(int &ch)
{
clrscr();
rthird(6);
int x,y,i,j,I;
char c;
float Y,X;
textcolor(1);
for(i=12,I=12;I<=17;I++,i--)
{
for(x=10;x<=70;x++)
{
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i);
cprintf("þ");
}
delay(200);
for(x=10;x<=70;x++)
{
gotoxy(x,I);
cprintf(" ");
gotoxy(x,i);
cprintf(" ");
}
}
for(x=10;x<=70;x++)
{
gotoxy(x,17);
cprintf("þ");
gotoxy(x,6);
cprintf("þ");
}
i=0;
textcolor(RED);
textbackground(GREEN);
gotoxy(15,10);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(15,11);
cprintf("³GROUND PROJECTION³");
gotoxy(15,12);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
textcolor(RED);
textbackground(GREEN);
gotoxy(45,10);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(45,11);
cprintf("³HEIGHT PROJECTION³");
gotoxy(45,12);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
do
{
if(i%2==0)
{
textcolor(14+BLINK);
gotoxy(16,11);
cprintf("GROUND PROJECTION");
}
else
{
textcolor(14+BLINK);
gotoxy(46,11);
cprintf("HEIGHT PROJECTION");
}
c=getch();
if(i%2==0)
{
textcolor(RED);
gotoxy(16,11);
cprintf("GROUND PROJECTION");
}
else
{
textcolor(RED);
gotoxy(46,11);
cprintf("HEIGHT PROJECTION");
}
i++;
}while(c!=13);
if(i%2==0)
ch=2;
else
ch=1;
textbackground(6);
for(i=6,I=17,Y=0,X=10;i>=1;I++,i--,X--,++Y)
{
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i);
cprintf("þ");
}
delay(200);
for(x=X;x<=70+Y;x++)
{
gotoxy(x,I);
cprintf(" ");
gotoxy(x,i);
cprintf(" ");
}
}
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
gotoxy(x,i+1);
cprintf("þ");
}
for(;I<=25;I++)
{
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf("þ");
}
delay(200);
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I);
cprintf(" ");
}
}
for(x=X;x<=70+Y;x++)
{
textcolor(1);
gotoxy(x,I-1);
cprintf("þ");
}
textbackground(6);
switch(ch)
{
case 1:
gotoxy(45,10);
cprintf(" ");
gotoxy(45,11);
cprintf(" ");
gotoxy(45,12);
cprintf(" ");
textcolor(RED);
textbackground(GREEN);
for(X=15,Y=10;Y>=2;Y--,X+=1.5)
{
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³GROUND PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
delay(100);
textbackground(6);
gotoxy(X,Y);
cprintf(" ");
gotoxy(X,Y+1);
cprintf(" ");
gotoxy(X,Y+2);
cprintf(" ");
}
textbackground(GREEN);
gotoxy(X+2,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X+2,Y+1);
cprintf("³GROUND PROJECTION³");
gotoxy(X+2,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
break;
case 2:
gotoxy(15,10);
cprintf(" ");
gotoxy(15,11);
cprintf(" ");
gotoxy(15,12);
cprintf(" ");
textcolor(RED);
textbackground(GREEN);
for(X=45,Y=10;Y>=2;Y--,X-=1.5)
{
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³HEIGHT PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
delay(100);
textbackground(6);
gotoxy(X,Y);
cprintf(" ");
gotoxy(X,Y+1);
cprintf(" ");
gotoxy(X,Y+2);
cprintf(" ");
}
textbackground(GREEN);
gotoxy(X,Y);
cprintf("ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸");
gotoxy(X,Y+1);
cprintf("³HEIGHT PROJECTION³");
gotoxy(X,Y+2);
cprintf("ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;");
}
}
void graph(float xS,float yS,float tS)
{
int i;
textcolor(YELLOW);
rthird(6);
for(i=2;i<=79;i++)
{
gotoxy(i,25);
if(i==2)
cprintf("Ô");
else if(i==79)
cprintf(">");
else
cprintf("Ñ");
}
for(i=1;i<=24;i++)
{
gotoxy(2,i);
if(i==1)
cprintf(" ");
else
cprintf("´");
}
textcolor(BLUE);
textbackground(5);
gotoxy(50,1);
cprintf("ÉÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(50,2);
cprintf("º SCALE º º");
gotoxy(50,3);
cprintf("ÌÍÍÍÍÍÍͼ º");
gotoxy(50,4);
cprintf("º º");
gotoxy(50,5);
cprintf("º º");
gotoxy(50,6);
cprintf("º º");
gotoxy(50,7);
cprintf("º º");
gotoxy(50,8);
cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
textcolor(YELLOW);
gotoxy(60,2);
cprintf("On X axis:-");
gotoxy(60,3);
cprintf("1 Division= %.1f m",xS);
gotoxy(54,4);
cprintf("On Y axis:-");
gotoxy(54,5);
cprintf("1 Division= %.1f m",yS);
gotoxy(54,6);
cprintf("For Time:-");
gotoxy(54,7);
cprintf("%.1f sec= 1 sec",tS);
}
void height(float u,float h,float xS,float yS,float tS)
{
float y,x,v,T,t;
textbackground(6);
x=y=1;
textcolor(CYAN);
for(y=h;(y>=0 && y<=23*yS) && (x>=0 && x<=xS*76);y-=yS)
{
t=sqrt((h-y)/5);
if(y==h)
T=t;
else
T=t-T;
delay(T*tS*1000);
x=sqrt((h-y)*(u*u)/5);
gotoxy(x/xS+2,25-y/yS);
cprintf("þ");
T=t;
}
}
void ground(float theta,float u,float r,float xS,float yS,float tS)
{
float A,B,T,t,x,y,vertex,R,H,D,Y;
A=5/(u*u*pow(cos(theta*M_PI/180),2));
B=tan(theta*M_PI/180);
textbackground(6);
textcolor(CYAN);
R=u*u*sin(2*theta*M_PI/180)/10;
H=u*u*pow(sin(theta*M_PI/180),2)/20;
/* for(x=0;x<=148;x+=2)
{
y=x*B-A*x*x;
T=x/(u*cos(theta*M_PI/180));
if(y>=-1 && y<=50)
{
gotoxy(x/2+2,25-y/2);
cprintf("þ");
if(x==0)
delay(T*2000);
else
delay((T-t)*2000);
cout<<T;
}
t=T;
} */
x=y=1;
for(Y=0,y=0;(y>=0 && y<=23*yS) && (x+r>=0 && x+r<=76*xS);Y+=yS)
{
if(Y<H)
{
D=sqrt(B*B-4*A*y);
x=(B-D)/(2*A);
T=(u*sin(theta*M_PI/180)-sqrt(u*u*pow(sin(theta*M_PI/180),2)-20*y))/10;
if(x>=0 && x<=xS*R)
{
if(y==0)
delay(0);
else
delay((T-t)*tS*1000);
gotoxy((x+r)/xS+2,25-y/yS);
cprintf("þ");
}
t=T;
y+=yS;
}
else
{
if(y<=0)
break;
y-=yS;
D=sqrt(B*B-4*A*y);
x=(B+D)/(2*A);
T=(u*sin(theta*M_PI/180)+sqrt(u*u*pow(sin(theta*M_PI/180),2)-20*y))/10;
if(x>=0 && x<=xS*R)
{
delay((T-t)*tS*1000);
gotoxy((x+r)/xS+2,25-y/yS);
cprintf("þ");
}
t=T;
}
}
}
void main()
{
clrscr();
int CH;
ch(CH);
switch(CH)
{
case 1:
float h,m,theta,e,dv,KE_,T,iv,KE,PE,TE,v,R,b,M,LoKEx,LoKEy,v1,v2,KEx,KEy,vx,vy,sint,cost,u,r=0,xS,yS,tS;
char c;
textcolor(RED);
textbackground(CYAN);
gotoxy(10,5);
cprintf("Enter Initial Velocity: m/s");
gotoxy(34,5);
cscanf("%f",&u);
gotoxy(10,7);
cprintf("Enter Angle: ø");
gotoxy(23,7);
cscanf("%f",&theta);
gotoxy(10,9);
cprintf("Enter Mass: kg");
gotoxy(22,9);
cscanf("%f",&m);
gotoxy(10,11);
cprintf("Enter mass of ground: kg");
gotoxy(32,11);
cscanf("%f",&M);
xS=3;
yS=3;
tS=1;
clrscr();
graph(xS,yS,tS);
vx=u*cos(theta*M_PI/180);
KEx=0.5*m*vx*vx;
vy=u*sin(theta*M_PI/180);
KEy=0.5*m*vy*vy;
TE=KEx+KEy;
T=u*sin(theta*M_PI/180)/5;
R=u*u*sin(2*theta*M_PI/180)/10;
ground(theta,u,r,xS,yS,tS);
// KE=TE;
// v=sqrt(2*KE/m);
// sint=vy/v;
// cost=vx/v;
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
// cout<<" LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<"PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" v="<<v<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
while(TE>1)
{
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
KEx=KEx-LoKEx;
KEy=KEy-LoKEy;
vx=sqrt(2*KEx/m);
vy=sqrt(2*KEy/m);
theta=vy/vx;
theta=atan(theta)*180/M_PI;
u=sqrt(vx*vx+vy*vy);
r+=R;
ground(theta,u,r,xS,yS,tS);
cost=vx/u;
sint=vy/u;
h=u*u*sint*sint/20;
R=u*u*2*sint*cost/10;
// PE=m*10*h;
TE=KEx+KEy;
T=u*sint/5;
// cout<<"\n\n\n LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<" PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
if(kbhit()!=0)
{
c=getch();
if(c==' ')
break;
}
}
getch();
break;
case 2:
r=0;
textcolor(RED);
textbackground(CYAN);
gotoxy(10,5);
cprintf("Enter Initial Velocity: m/s");
gotoxy(34,5);
cscanf("%f",&vx);
gotoxy(10,7);
cprintf("Enter Height: m");
gotoxy(24,7);
cscanf("%f",&h);
gotoxy(10,9);
cprintf("Enter Mass: kg");
gotoxy(22,9);
cscanf("%f",&m);
gotoxy(10,11);
cprintf("Enter mass of ground: kg");
gotoxy(32,11);
cscanf("%f",&M);
xS=3;
yS=3;
tS=1;
/* gotoxy(10,15);
cprintf("Enter Scale for X axis: m");
gotoxy(34,15);
cscanf("%f",&xS);
gotoxy(10,17);
cprintf("Enter Scale for Y axis: m");
gotoxy(34,17);
cscanf("%f",&yS);
gotoxy(10,19);
cprintf("Enter Scale For Time: sec");
gotoxy(32,19);
cscanf("%f",&tS);*/
clrscr();
graph(xS,yS,tS);
height(vx,h,xS,yS,tS);
PE=m*10*h;
KEx=0.5*m*vx*vx;
KEy=0;
TE=PE+KEx+KEy;
T=sqrt(h/5);
R=vx*T;
vy=10*T;
KE=TE;
KEy=KE-KEx;
theta=vy/vx;
theta=atan(theta)*180/M_PI;
v=sqrt(2*KE/m);
sint=vy/v;
cost=vx/v;
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
// cout<<" LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<"PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" v="<<v<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
while(TE>1)
{
LoKEx=m*M*vx*vx/(2*(m+M));
LoKEy=m*M*vy*vy/(2*(m+M));
KEx=KEx-LoKEx;
KEy=KEy-LoKEy;
vx=sqrt(2*KEx/m);
vy=sqrt(2*KEy/m);
theta=vy/vx;
u=sqrt(vx*vx+vy*vy);
r+=R;
theta=atan(theta)*180/M_PI;
ground(theta,u,r,xS,yS,tS);
cost=vx/u;
sint=vy/u;
h=u*u*sint*sint/20;
R=u*u*2*sint*cost/10;
PE=m*10*h;
TE=KEx+KEy;
T=u*sint/5;
// cout<<"\n\n\n LoKEx="<<LoKEx<<" LoKEy="<<LoKEy<<" PE="<<PE<<" KEx="<<KEx<<" KEy="<<KEy<<" TE="<<TE<<" T="<<T<<" R="<<R<<"\n vx="<<vx<<" vy="<<vy<<" TANTETHA="<<theta<<"\n H="<<h<<" sint="<<sint<<"\n cost="<<cost<<" u="<<u;
if(kbhit()!=0)
{
c=getch();
if(c==' ')
break;
}
}
getch();
break;
}
}
===========================================================================
No comments:
Post a Comment