title: JavaScript IE rotation transform maths
body: <p>I am working on setting the rotation of an element with JavaScript, I know this is easy to achieve if you want to set to a 90 degree angle but this is not what I want. Because I want to set to strange angles such as 20 degrees I need to use the transform filter. I know the layout of this but I was wondering how I calculate the four values, at first I tried this.</p>
  
  <pre><code>calSin = Math.sin(parseInt(css[c]));
  calCos = Math.cos(parseInt(css[c]));
  element.style.filter = 'progid:DXImageTransform.Microsoft.Matrix(M11=' + calCos + ', M12=-' + calSin + ',M21=' + calSin + ', M22=' + calCos + ', sizingMethod="auto expand")';
  </code></pre>
  
  <p>But as you can see, this was never going to work, I was just taking a stab in the dark. Due to maths not being my strong point I was wondering if anyone could help me calculate the values?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Okay! Got it working with the following code.</p>
  
  <pre><code>radians = parseInt(css[c]) * Math.PI * 2 / 360;
  calSin = Math.sin(radians);
  calCos = Math.cos(radians);
  element.style.filter = 'progid:DXImageTransform.Microsoft.Matrix(M11=' + calCos + ', M12=-' + calSin + ',M21=' + calSin + ', M22=' + calCos + ', sizingMethod="auto expand")';
  </code></pre>
  
  <p>But now the question is how do I make it rotate from the center rather than top left?</p>