W3C home > Mailing lists > Public > www-style@w3.org > February 2012

Re: [css3-transforms] Pseudo code for matrix decomposing

From: Chris Marrin <cmarrin@apple.com>
Date: Tue, 14 Feb 2012 10:28:53 -0800
Cc: "www-style@w3.org CSS" <www-style@w3.org>
Message-id: <A3D78949-5B35-4AEF-8588-0D730DF2742F@apple.com>
To: Dirk Schulze <dschulze@adobe.com>

On Feb 14, 2012, at 10:03 AM, Dirk Schulze wrote:

> Hi,
> 
> At the moment the CSS Transforms specification (http://dev.w3.org/csswg/css3-transforms/) provides some pseudo code to decompose 4x4 matrices. The decomposing is needed for transitions and animations of transforms. The current code uses euler angles for rotate. This might be easier to understand. Nevertheless, the WebKit implementation uses quaternion[1][2] for decomposing. Quaternion is another number system that extends the complex numbers. It helps avoiding some mathematical singularities like the hairy ball theorem[1].
> 
> Should the CSS Transform specification add a normative section that implementations should use quaternion? Should the pseudo code get updated with a maybe more complex quaternion version? Should the animation section get updated how to deal with quaternion?

Quaternions are almost always the preferred method of decomposing rotations if your intent is to do animations. Euler angles are prone to gimbal lock [1] which makes animation undefined when passing through certain angles. Quaternions don't have this problem and can be animated without ambiguity using a slerp function [2]. So if we do this it will require a small change to the unmatrix pseudocode and the addition of some pseudocode for slerp.

Webkit uses quaternions and a slerp function. 

[1] http://en.wikipedia.org/wiki/Gimbal_lock
[2] http://en.wikipedia.org/wiki/Slerp

-----
~Chris
cmarrin@apple.com
Received on Tuesday, 14 February 2012 18:29:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:50 GMT