All pastes #395041 Raw Edit

Untitled

public cpp v1 · immutable
·published 2007-03-14 19:16 UTC
rendered paste body
int tir_parabolic(int x_inici, int y_inici, double angle, double forca, int x_actual, int vent){	double v_x,v_y; // Velocitats inicials	double t; // Temps transcorregut		v_x = cos((double)angle)*(double)forca;	v_y = sin((double)angle)*(double)forca;	if ((v_x*v_x-(double)(2*vent*(x_inici-x_actual))) != 0) {		t = (-v_x - sqrt(v_x*v_x-(double)(2*vent*(x_inici-x_actual))))/(double)vent;				if (t < 0) 			t = (-v_x + sqrt(v_x*v_x-(double)(2*vent*(x_inici-x_actual))))/(double)vent;	}		if (vent == 0) {		t = ((float)x_actual-(float)x_inici)/v_x;	}		if (v_x==0) {		return -1;	}	else {		return (int)(y_inici+(int)v_y*t-(int)(GRAVETAT/2.0)*(t*t));	}}