src/physics.js
/*
 * Adjust a body angle to the given heading.
 */
Adjust a body angle to the given heading.
Adjust a body angle to the given heading .
function adjustVelocity(body, vel, accel) {
	var limit = accel / param.Rate;
	var v = body.velocity;
	var dx = vel[0] - v[0], dy = vel[1] - v[1];
	var d2 = dx * dx + dy * dy;
	if (d2 < 0.01) {
		return;
	}
	if (d2 > limit * limit) {
		var a = limit / Math.sqrt(d2);
		dx *= a;
		dy *= a;
	}
	v[0] += dx;
	v[1] += dy;
}
function adjustVelocity ( body , vel , accel ) { var limit = accel / param . Rate ; var v = body . velocity ; var dx = vel [ 0 ] - v [ 0 ] , dy = vel [ 1 ] - v [ 1 ] ; var d2 = dx * dx + dy * dy ; if ( d2 < 0.01 ) { return ; } if ( d2 > limit * limit ) { var a = limit / Math . sqrt ( d2 ) ; dx *= a ; dy *= a ; } v [ 0 ] += dx ; v [ 1 ] += dy ; }
Adjust a body angle to the given heading.
Adjust a body angle to the given heading .