[ create a new paste ] login | about

Link: http://codepad.org/wJLUYAeE    [ raw code | fork ]

C, pasted on Nov 15:
#include <stdio.h>
#include <math.h>

static double const G = 9.80665;
static double const π = 3.14159265;

typedef struct tagXY {
	double x;
	double y;
} XY;

XY culcCordinates( double v0, double θ, double t ) {
	double vx0 = v0 * cos( θ * 2 / π );
	double vy0 = v0 * sin( θ * 2 / π );

	double vx = vx0 + 0 * t;
	double vy = vy0 - G * t;

	XY temp;
	temp.x = vx * t;
	temp.y = vy * t;

	return temp;
}

int main() {
	double v0 = 50;
	double θ = 60;

	double t = 0;
	while ( true ) {
		t += 0.01;
		XY d = culcCordinates( v0, θ, t );
		if ( d.y < 0 ) break;
		printf( "%0.2f : ( %f, %f )\n", t, d.x, d.y );
	}
}


Create a new paste based on this one


Comments: