4

I want to know how to get the rotateX and rotateY values of a matrix3d such as this:

matrix3d(0.9999999970415847, 0, 0.00007692093651178932, 0, 0, 1, 0, 0, -0.00007692093651178932, 0, 0.9999999970415847, 0, 0, 0, 300, 1)

does anybody know how to this ? I would really appreciate the help especially since I am not really the math type of person. thnx!

AJ Naidas
  • 1,424
  • 7
  • 25
  • 47

1 Answers1

5

I'm not good at math either, so this needs some checking by someone with more knowledge than me:

var matrix = new WebKitCSSMatrix(el.style.webkitTransform);
var rotationX = Math.acos(matrix.a) * (180/pi);
var rotationY = Math.asin(matrix.b) * (180/pi);

You can view a demo here:

http://jsfiddle.net/YsCF5/

methodofaction
  • 70,885
  • 21
  • 151
  • 164
  • A quick note, this was written a long time ago and the CSSMatrix feature was a non-standard proposal. MDN now recommends the following: https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix – dudewad Feb 18 '16 at 21:06