Last active
November 9, 2016 07:27
-
-
Save AndriyBas/4f60539d13be10efb5571d13c53bb7f8 to your computer and use it in GitHub Desktop.
all the math how to create Matrix from the model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate params | |
float topLeftX = layer.getX() * canvasWidth; | |
float topLeftY = layer.getY() * canvasHeight; | |
// center - for rotation | |
float centerX = topLeftX + getWidth() * holyScale * 0.5F; | |
float centerY = topLeftY + getHeight() * holyScale * 0.5F; | |
float rotationInDegree = layer.getRotationInDegrees(); | |
float scaleX = layer.getScale(); | |
float scaleY = layer.getScale(); | |
// applying transformations : L = S * R * T | |
// scale | |
matrix.preScale(scaleX, scaleY, centerX, centerY); | |
// rotate | |
matrix.preRotate(rotationInDegree, centerX, centerY); | |
// translate | |
matrix.preTranslate(topLeftX, topLeftY); | |
// applying holy scale - S`, the result will be : L = S * R * T * S` | |
matrix.preScale(holyScale, holyScale); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment