<commit_before>define([
	"physics/vector2",
	"physics/vectortools"
], function(
	Vector2,
	VectorTools
) {
	var ClosedShape = function(input) {
		this.mLocalVertices = input || []; // Vectorlist
	};
		
	ClosedShape.prototype.begin = function() {
		this.mLocalVertices.length = 0; // clear()
		return this;
	};

	ClosedShape.prototype.addVertex = function(vec) {
		this.mLocalVertices.push(vec);
		//return this.mLocalVertices.length;
		return this;
	};

	ClosedShape.prototype.finish = function(recenter) {
		recenter = recenter || true;

		if(recenter) {
			// find the average location of all of the vertices, this is our geometrical center.
			var center = Vector2.Zero.copy();
			
			for(var i = 0; i < this.mLocalVertices.length; i++)
				center.addSelf(this.mLocalVertices[i]);
			
			center.divFloatSelf(this.mLocalVertices.length);
			
			// now subtract this from each element, to get proper "local" coordinates.
			for (var i = 0; i < this.mLocalVertices.length; i++)
				this.mLocalVertices[i].subSelf(center);
		};
		return this;
	};

	ClosedShape.prototype.getVertices = function() { return this.mLocalVertices; };

	ClosedShape.prototype.transformVertices = function(worldPos, angleInRadians, scale, outList) {
		outList = outList || [];

		var that = this;
		
		for(var i = 0; i < this.mLocalVertices.length; i++) {
			(function() {
				// apply scale vector
				var v = that.mLocalVertices[i].mulVector(scale);

				// rotate the point, and then translate.
				v.rotateSelf(angleInRadians);
				v.addSelf(worldPos);

				outList[i] = v;
			})();
		};
		
		return outList;
	};<commit_msg>use matrix to transform a closed shapes vertices<commit_after>define([
    "num/matrix3x3",
	"physics/vector2",
	"physics/vectortools"
], function(
    AffineTransformation,
	Vector2,
	VectorTools
) {
	var ClosedShape = function(input) {
		this.mLocalVertices = input || []; // Vectorlist
	};
		
	ClosedShape.prototype.begin = function() {
		this.mLocalVertices.length = 0; // clear()
		return this;
	};

	ClosedShape.prototype.addVertex = function(vec) {
		this.mLocalVertices.push(vec);
		//return this.mLocalVertices.length;
		return this;
	};

	ClosedShape.prototype.finish = function(recenter) {
		recenter = recenter || true;

		if(recenter) {
			// find the average location of all of the vertices, this is our geometrical center.
			var center = Vector2.Zero.copy();
			
			for(var i = 0; i < this.mLocalVertices.length; i++)
				center.addSelf(this.mLocalVertices[i]);
			
			center.divFloatSelf(this.mLocalVertices.length);
			
			// now subtract this from each element, to get proper "local" coordinates.
			for (var i = 0; i < this.mLocalVertices.length; i++)
				this.mLocalVertices[i].subSelf(center);
		};
		return this;
	};

	ClosedShape.prototype.getVertices = function() { return this.mLocalVertices; };

	ClosedShape.prototype.transformVertices = function(worldPos, angleInRadians, scale, outList) {
        var transform = AffineTransformation.Identity.copy();
        transform.translateSelf(worldPos);
        transform.rotateSelf(angleInRadians * 180 / Math.PI, Vector2.Zero);
        transform.scaleSelf(scale);
		outList = outList || [];

		for(var i = 0; i < this.mLocalVertices.length; i++) {
			outList[i] = transform.transform(this.mLocalVertices[i]);;
		};
		
		return outList;
	};
{'fraction_non_alphanumeric': 0.13397706698853348, 'fraction_numerical': 0.006035003017501509, 'mean_word_length': 3.642857142857143, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2853651', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1077, 'n_words': 234}