W3C home > Mailing lists > Public > public-fx@w3.org > January to March 2014

[css-transforms] matrix interpolation

From: <css3@userks.e4ward.com>
Date: Wed, 08 Jan 2014 12:17:35 -0500
Message-ID: <52CD882F.6020408@yahoo.com>
To: public-fx@w3.org

It is delightful to see 3D capabilities coming to CSS styling.

It is disappointing to see the choice for matrix interpolation.

Specifically, I'm looking at Section 20: Interpolation of matrices.


The draft standard specifies using a method found in Graphics Gems II,
edited by Jim Arvo.

However, in 1992 I published a paper with Tom Duff, entitled "Matrix
Animation and Polar Decomposition", which has important advantages set
out there.


For those who do not know the 3D computer graphics literature well, Tom
Duff (now at Pixar) has two Academy awards for technical contributions,
and I introduced quaternion animation to computer graphics. So perhaps
our ideas our worth considering.

And if you had only looked at Graphics Gems IV, you would have found my
"Polar Matrix Decomposition" on pages 207 through 221, complete with
implementation code!


We didn't have any special insight into meaningful ways to deal with
perspective elements in a general (4x4) matrix transform, so we
improvised for that. Translation is, of course, trivial to split off
from an affine transform. So the heart of the paper is how best to split
a (3x3) linear transform into meaningful primitives.

I have great respect for Spencer Thomas, who wrote "unmatrix"; nor is he
the only one to have taken a stab at this puzzle. Animating matrices is
generally a method of last resort, and part of the problem is what
constitutes a good solution.

We claim that a lesser-known numerical analysis split known as the Polar
Decomposition has a number of advantages over prior efforts, including
an explicit criterion for a good solution.

For purposes of CSS transforms, note that it is trivial to compute the
Polar Decomposition of a 2x2 matrix. (The original paper explains how.)

Since the paper was written, numerical analysts have found even more
clever ways to do the split in higher dimensions; 3x3 matrices require
little work even with a simple Newton iteration.

  Q_{0} = M
  Q_{i+1} = ( Q_{i} + Q_{i}^{-T} ) / 2

That is, we set Q to the 3x3 matrix M, and repeatedly average Q with its
inverse transpose to converge Q to an orthogonal matrix.

A non-singular matrix M has a unique nearest orthogonal matrix, which is
precisely what we will get -- and what we want. (See the paper.)

Having cleanly split off M's rotation part (possibly with a negation) as
Q, what remains is purely scaling.

  S = Q^{T} M

It is unrealistic to expect S to be diagonal; Polar Decomposition is
"physical", essentially independent of coordinate system. So S will in
general take the form it must when the scaling axes are not the same as
the matrix axes: it will be symmetric and non-negative definite.

The paper lays out the options and implications for animation once we
have the split.

If you have already considered and discarded Polar Decomposition, my
apologies. If not, I urge you to try it.

 -- Ken Shoemake
Received on Thursday, 9 January 2014 09:14:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:49:48 UTC