Creating a programme for parabolic path/parabolic motion.
-The object is shot from the ground and there must be 4 input datas : the duration of time (t),the angle,initial velocity and the time interval of the displacement(delta t).
-The output should be the displacement in both the x and y direction.
- projection time is set to 0
- the position after t seconds is calculated by delta t second intervals(t and delta t is also input after the program runs).
- the result is output to the file, use Excel to make graph with it
Here's what I have tried so far and there are many things that I am having problems with.
Somebody tell me how do I write out the equation correctly?And how do I define delta t?I know what it is but i don't know how to write that out.
And please,correct my mistakes.
#include <stdio.h>
#include <math.h>
#define g 9.8
int main()
{
double t, x, y, angle, Vo, deltat;
char buf[256];
int i;
FILE* fp;
printf( "t = " );
fgets( buf, 256, stdin );
sscanf( buf, "%lf\n", &t );
printf( "deltat = " );
fgets( buf, 256, stdin );
sscanf( buf, "%lf\n", &deltat );
printf("initial velocity = ");
sscanf( buf, "%lf\n", &Vo );
fgets( buf, 256, stdin );
printf( "angle = " );
sscanf( buf, "%lf\n", &angle );
fgets( buf, 256, stdin );
fp = fopen( "z:\\FreeFall.txt", "w" );
for( i = 0; i < t; i++ ) {
y = Vo*sin(angle)*deltat - ( g / 2.0 ) *deltat * deltat;
x = Vo*cos(angle)*deltat;
printf( "t= %f, y= %f ,x= %f\n", t, x, y );
fprintf( fp, "t=, %f, y=, %f ,x= %f\n", t, x, y );
}
fprintf( stderr, "File z:\\FreeFall.txt was created\n" );
fclose( fp );
return 0;
}
and this is the results I get.
picture1.JPG 36.22K
56 downloads
Edited by aruwin, 11 December 2011 - 03:16 AM.


Sign In
Create Account


Back to top









