2D Matrix scale and rotation extraction


/ Published in: ActionScript 3
Save to your folder(s)

Used this snippet in various projects.


Copy this code and paste it in your HTML
  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;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.