Updated code for GetTransformedPoint

This commit is contained in:
Felipe Alfonso 2017-06-20 16:47:43 -04:00
parent dc05c29740
commit 2341f7752f
2 changed files with 17 additions and 4 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '2ac4ba60-552b-11e7-965c-39a419b0ea9b'
build: '02a4bdd0-55d7-11e7-87f5-37983a7cf73e'
};
module.exports = CHECKSUM;

View file

@ -10,9 +10,22 @@ var GetTransformedPoint = function (matrix, gameObject, x, y, output)
{
if (output === undefined) { output = { x: 0, y: 0 }; }
matrix.applyITRS(gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY);
// matrix.invert();
matrix.transformPoint(x, y, output);
matrix.applyITRS(gameObject.x, gameObject.y, -gameObject.rotation, gameObject.scaleX, gameObject.scaleY);
matrix.invert();
// matrix.transformPoint(x, y, output);
var ma = matrix.matrix;
var a = ma[0];
var b = ma[1];
var c = ma[2];
var d = ma[3];
var e = ma[4];
var f = ma[5];
var tx = x * a + y * c + e;
var ty = x * b + y * d + f;
output.x = tx;
output.y = ty;
// var a = matrix.matrix[0];
// var b = matrix.matrix[1];