W3C home > Mailing lists > Public > www-style@w3.org > September 2010

Better matrix decomposition for animation

From: Behdad Esfahbod <behdad@behdad.org>
Date: Wed, 22 Sep 2010 15:20:35 -0400
Message-ID: <4C9A5703.1000006@behdad.org>
To: "www-style@w3.org list" <www-style@w3.org>

I was reading the CSS 2D Transforms Module Level 3 W3C Working Draft 01
December 2009 today.


And it occurred to me that the "7. Matrix decomposition for animation" is
incongruous to the rest of the document in that it results in 3d operations
that cannot be expressed as CSS 2D transforms!  It's also unnecessarily
complex, unstable, and generally overcomplicated because it's a general
routine decomposing a 3d matrix whereas we just need a 2d matrix
decomposition.  So I derived one today.  Not tested, but is very easy to
derive and test.

A matrix(a,b,c,d,e,f) transform is decomposed into the following simple

  transform(e,f) rotate(r) skew(s) scale(aa,dd)


  r  = atan2(b, a);
  aa = sqrt(a*a+b*b);
  cc = cos(r)*c - sin(r)*d;
  dd = sin(r)*c + cos(r)*d;
  s  = atan2(cc,dd);

That's all.  I find this considerably simpler, much faster, more stable, and
more intuitive than of the 5 pages worth of code currently listed in the spec.

Or am I completely missing the point?

My 0.02CAD,
Received on Wednesday, 22 September 2010 19:21:11 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:50 UTC