Posted By

TheRabbitFlash on 10/17/14


Tagged

rotate scale extract matrix


Versions (?)

2D Matrix scale and rotation extraction


 / Published in: ActionScript 3
 

URL: http://www.infogroupindia.com/blog/posts/589/action-script-3-2d-matrix-scale-and-rotation-extraction

Used this snippet in various projects.

  1. rotation = Math.atan( -mat.c / mat.a);
  2. scaleX = Math.sqrt((mat.a * mat.a) + (mat.c * mat.c));
  3. scaleY = Math.sqrt((mat.b * mat.b) + (mat.d * mat.d));
  4.  
  5. sign = Math.atan(-c / a);
  6. rad = Math.acos(a / scaleX);
  7. deg = rad * degree;
  8.  
  9. if (deg > 90 && sign > 0)
  10. {
  11. rotation = (360 - deg) * radian;
  12. }
  13. else if (deg < 90 && sign < 0)
  14. {
  15. rotation = (360 - deg) * radian;
  16. }
  17. else
  18. {
  19. rotation = rad;
  20. }
  21. rotationInDegree = rotation * degree;

Report this snippet  

You need to login to post a comment.