exports.add = exports.translate = function(pt, dx, dy) {
	return typeof dx == 'number' ?
		{
			x: pt.x + dx,
			y: pt.y + dy
		}
		: {
			x: pt.x + dx.x,
			y: pt.y + dx.y
		};
}

exports.subtract = function(pt, dx, dy) {
	return typeof dx == 'number' ?
		{
			x: pt.x - dx,
			y: pt.y - dy
		}
		: {
			x: pt.x - dx.x,
			y: pt.y - dx.y
		};
}

exports.addMagnitude = function(pt, m) {
	return exports.setMagnitude(pt, exports.getMagnitude(pt) + m);
}

exports.setMagnitude = function(pt, m) {
	var theta = Math.atan2(pt.y, pt.x);
	return {
		x: m * Math.cos(theta),
		y: m * Math.sin(theta)
	};
}

exports.getMagnitude = function(pt) {
	return Math.sqrt(pt.x * pt.x + pt.y * pt.y);
}

exports.rotate = function(pt, r) {
	var x = pt.x,
		y = pt.y,
		cosr = Math.cos(r),
		sinr = Math.sin(r);
	
	return {
		x: x * cosr - y * sinr,
		y: x * sinr + y * cosr
	};
}

exports.inBox = function(pt, x1, y1, x2, y2) { return pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2; }
@@ -332,32 +332,112 @@
  - dx.y%0A%09%09%7D;%0A%7D%0A%0A
+exports.scale = function(s, pt) %7B%0A%09return %7B%0A%09%09x: pt.x * s,%0A%09%09y: pt.y * s%0A%09%7D;%0A%7D%0A%0A
 exports.addMagni

add a scale function which multiplies a 2D vector by a scalar