<commit_before>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.rotate = function(pt, r) {
	var x = pt.x,
		y = pt.y,
		cosr = Math.cos(r),
		sinr = Math.sin(r);<commit_msg>add functions to Math2D to manipulate magnitude of a vector independent of it's angle<commit_after>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);
{'fraction_non_alphanumeric': 0.187454412837345, 'fraction_numerical': 0.0014587892049598833, 'mean_word_length': 2.338199513381995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081253', 'n_tokens_mistral': 678, 'n_tokens_neox': 613, 'n_words': 146}