Saturday, May 18, 2024

Android Transformation Matrix

Transformation Matrix

Based on the Affine transformation examples shown in https://en.wikipedia.org/wiki/Affine_transformation , a 2D transformation matrix for scale, skew and translation in x and y axes can be shown as follows:

scaleX      skewX        tranxX

skewY      scaleY        transY

0               0                1

For example,

In order to scale a canvas by 2x in x and y axes, the transform that needs to be applied (multiplied with the transform matrix of the canvas) is:

2                   0                   0

0                   2                   0

0                   0                   1

So a canvas that is scaled using the above transformation matrix would look like:

           Original                                                     Transformed

 
 


No comments:

Post a Comment