Skip to content

Commit

Permalink
added transformX() and transformY() methods
Browse files Browse the repository at this point in the history
code is from openfl.geom.Matrix
  • Loading branch information
Beeblerox committed Nov 30, 2016
1 parent 7815a0a commit dcc66b3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flixel/math/FlxMatrix.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,30 @@ class FlxMatrix extends Matrix
this.setTo(b, -a, d, -c, ty, -tx);
return this;
}

/**
* Transforms x coordinate of the point.
* Took original code from openfl.geom.Matrix (which isn't available on flash target).
*
* @param px x coordinate of the point
* @param py y coordinate of the point
* @return transformed x coordinate of the point
*/
public inline function transformX(px:Float, py:Float):Float
{
return px * a + py * c + tx;
}

/**
* Transforms y coordinate of the point.
* Took original code from openfl.geom.Matrix (which isn't available on flash target).
*
* @param px x coordinate of the point
* @param py y coordinate of the point
* @return transformed y coordinate of the point
*/
public inline function transformY(px:Float, py:Float):Float
{
return px * b + py * d + ty;
}
}

1 comment on commit dcc66b3

@MSGhero
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's originally from matrix multiplication 😁

Please sign in to comment.